diff options
author | zeripath <art27@cantab.net> | 2020-01-27 10:26:53 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-27 10:26:53 +0000 |
commit | 51f6a7ab1022342d8e552ffa9925118d8c692a96 (patch) | |
tree | b3326e38e813812e3d1e0f33dbb09e2792dc636a /routers | |
parent | 03cb168127c0139490857be344a78fd37d46e804 (diff) | |
download | gitea-51f6a7ab1022342d8e552ffa9925118d8c692a96.tar.gz gitea-51f6a7ab1022342d8e552ffa9925118d8c692a96.zip |
On merge of already closed PR redirect back to the pulls page (#10010)
* On merge of already closed PR redirect back to the pulls page
* More redirects
* As per @6543
Co-Authored-By: 6543 <6543@obermui.de>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/repo/pull.go | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/routers/repo/pull.go b/routers/repo/pull.go index 655be2e82e..b4760fd527 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -679,7 +679,13 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) { return } if issue.IsClosed { - ctx.NotFound("MergePullRequest", nil) + if issue.IsPull { + ctx.Flash.Error(ctx.Tr("repo.pulls.is_closed")) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index)) + return + } + ctx.Flash.Error(ctx.Tr("repo.issues.closed_title")) + ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index)) return } @@ -691,12 +697,20 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) { return } if !allowedMerge { - ctx.NotFound("MergePullRequest", nil) + ctx.Flash.Error(ctx.Tr("repo.pulls.update_not_allowed")) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index)) return } - if !pr.CanAutoMerge() || pr.HasMerged { - ctx.NotFound("MergePullRequest", nil) + if !pr.CanAutoMerge() { + ctx.Flash.Error(ctx.Tr("repo.pulls.no_merge_not_ready")) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index)) + return + } + + if pr.HasMerged { + ctx.Flash.Error(ctx.Tr("repo.pulls.has_merged")) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index)) return } |