summaryrefslogtreecommitdiffstats
path: root/routers/web/repo/issue.go
diff options
context:
space:
mode:
authora1012112796 <1012112796@qq.com>2022-01-04 03:45:58 +0800
committerGitHub <noreply@github.com>2022-01-03 20:45:58 +0100
commit637c3ec5d82f9d727724cc362aea37eeb2f64b40 (patch)
tree2b3af5ec2e6595d037a78b8a45e0a95210ab7d14 /routers/web/repo/issue.go
parent650a50a7ba8efcd8d02c4c93e5abc19f27e6c4b5 (diff)
downloadgitea-637c3ec5d82f9d727724cc362aea37eeb2f64b40.tar.gz
gitea-637c3ec5d82f9d727724cc362aea37eeb2f64b40.zip
Don't delete branch if other PRs with this branch are open (#18164)
fix #18149 Signed-off-by: a1012112796 <1012112796@qq.com>
Diffstat (limited to 'routers/web/repo/issue.go')
-rw-r--r--routers/web/repo/issue.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index d55b6c96b6..ea16de3950 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -1600,11 +1600,23 @@ func ViewIssue(ctx *context.Context) {
} else {
ctx.Data["WontSignReason"] = "not_signed_in"
}
- ctx.Data["IsPullBranchDeletable"] = canDelete &&
+
+ isPullBranchDeletable := canDelete &&
pull.HeadRepo != nil &&
git.IsBranchExist(ctx, pull.HeadRepo.RepoPath(), pull.HeadBranch) &&
(!pull.HasMerged || ctx.Data["HeadBranchCommitID"] == ctx.Data["PullHeadCommitID"])
+ if isPullBranchDeletable && pull.HasMerged {
+ exist, err := models.HasUnmergedPullRequestsByHeadInfo(pull.HeadRepoID, pull.HeadBranch)
+ if err != nil {
+ ctx.ServerError("HasUnmergedPullRequestsByHeadInfo", err)
+ return
+ }
+
+ isPullBranchDeletable = !exist
+ }
+ ctx.Data["IsPullBranchDeletable"] = isPullBranchDeletable
+
stillCanManualMerge := func() bool {
if pull.HasMerged || issue.IsClosed || !ctx.IsSigned {
return false