Skip to content

Commit 6fb3547

Browse files
authored
Always honor user's choice for "delete branch after merge" (#36281)
Fix #36280
1 parent d2baa81 commit 6fb3547

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

routers/web/repo/pull.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"code.gitea.io/gitea/modules/graceful"
3333
issue_template "code.gitea.io/gitea/modules/issue/template"
3434
"code.gitea.io/gitea/modules/log"
35+
"code.gitea.io/gitea/modules/optional"
3536
"code.gitea.io/gitea/modules/setting"
3637
"code.gitea.io/gitea/modules/templates"
3738
"code.gitea.io/gitea/modules/util"
@@ -1136,11 +1137,9 @@ func MergePullRequest(ctx *context.Context) {
11361137
message += "\n\n" + form.MergeMessageField
11371138
}
11381139

1139-
deleteBranchAfterMerge, err := pull_service.ShouldDeleteBranchAfterMerge(ctx, form.DeleteBranchAfterMerge, ctx.Repo.Repository, pr)
1140-
if err != nil {
1141-
ctx.ServerError("ShouldDeleteBranchAfterMerge", err)
1142-
return
1143-
}
1140+
// There is always a checkbox on the UI (the DeleteBranchAfterMerge is nil if the checkbox is not checked),
1141+
// just use the user's choice, don't use pull_service.ShouldDeleteBranchAfterMerge to decide
1142+
deleteBranchAfterMerge := optional.FromPtr(form.DeleteBranchAfterMerge).Value()
11441143

11451144
if form.MergeWhenChecksSucceed {
11461145
// delete all scheduled auto merges

0 commit comments

Comments
 (0)