0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-23 17:11:45 +02:00

Always honor user's choice for "delete branch after merge" (#36281) (#36286)

Backport #36281 by wxiaoguang

Fix #36280

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Giteabot 2026-01-03 11:06:10 +08:00 committed by GitHub
parent 163113d173
commit 76b6e94b5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -32,6 +32,7 @@ import (
"code.gitea.io/gitea/modules/graceful"
issue_template "code.gitea.io/gitea/modules/issue/template"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/optional"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/util"
@ -1100,11 +1101,9 @@ func MergePullRequest(ctx *context.Context) {
message += "\n\n" + form.MergeMessageField
}
deleteBranchAfterMerge, err := pull_service.ShouldDeleteBranchAfterMerge(ctx, form.DeleteBranchAfterMerge, ctx.Repo.Repository, pr)
if err != nil {
ctx.ServerError("ShouldDeleteBranchAfterMerge", err)
return
}
// There is always a checkbox on the UI (the DeleteBranchAfterMerge is nil if the checkbox is not checked),
// just use the user's choice, don't use pull_service.ShouldDeleteBranchAfterMerge to decide
deleteBranchAfterMerge := optional.FromPtr(form.DeleteBranchAfterMerge).Value()
if form.MergeWhenChecksSucceed {
// delete all scheduled auto merges