mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-25 11:22:16 +00:00
Don't delete branch if other PRs with this branch are open (#18164)
fix #18149 Signed-off-by: a1012112796 <1012112796@qq.com>
This commit is contained in:
parent
650a50a7ba
commit
637c3ec5d8
5 changed files with 68 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue