Skip to content

Commit 51f6a7a

Browse files
zeripath6543
andauthored
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 <[email protected]>
1 parent 03cb168 commit 51f6a7a

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

routers/repo/pull.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,13 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) {
679679
return
680680
}
681681
if issue.IsClosed {
682-
ctx.NotFound("MergePullRequest", nil)
682+
if issue.IsPull {
683+
ctx.Flash.Error(ctx.Tr("repo.pulls.is_closed"))
684+
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index))
685+
return
686+
}
687+
ctx.Flash.Error(ctx.Tr("repo.issues.closed_title"))
688+
ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index))
683689
return
684690
}
685691

@@ -691,12 +697,20 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) {
691697
return
692698
}
693699
if !allowedMerge {
694-
ctx.NotFound("MergePullRequest", nil)
700+
ctx.Flash.Error(ctx.Tr("repo.pulls.update_not_allowed"))
701+
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index))
695702
return
696703
}
697704

698-
if !pr.CanAutoMerge() || pr.HasMerged {
699-
ctx.NotFound("MergePullRequest", nil)
705+
if !pr.CanAutoMerge() {
706+
ctx.Flash.Error(ctx.Tr("repo.pulls.no_merge_not_ready"))
707+
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index))
708+
return
709+
}
710+
711+
if pr.HasMerged {
712+
ctx.Flash.Error(ctx.Tr("repo.pulls.has_merged"))
713+
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index))
700714
return
701715
}
702716

0 commit comments

Comments
 (0)