Skip to content

Commit 0422e6b

Browse files
committed
Make retarget optional, keep default behaviour without option
1 parent 91de000 commit 0422e6b

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

modules/setting/repository.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ var (
7878
DefaultMergeMessageOfficialApproversOnly bool
7979
PopulateSquashCommentWithCommitMessages bool
8080
AddCoCommitterTrailers bool
81+
RetargetChildsOnClose bool
8182
} `ini:"repository.pull-request"`
8283

8384
// Issue Setting
@@ -199,6 +200,7 @@ var (
199200
DefaultMergeMessageOfficialApproversOnly bool
200201
PopulateSquashCommentWithCommitMessages bool
201202
AddCoCommitterTrailers bool
203+
RetargetChildsOnClose bool
202204
}{
203205
WorkInProgressPrefixes: []string{"WIP:", "[WIP]"},
204206
// Same as GitHub. See

routers/api/v1/repo/pull.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"code.gitea.io/gitea/modules/git"
2525
"code.gitea.io/gitea/modules/log"
2626
"code.gitea.io/gitea/modules/notification"
27+
"code.gitea.io/gitea/modules/setting"
2728
api "code.gitea.io/gitea/modules/structs"
2829
"code.gitea.io/gitea/modules/timeutil"
2930
"code.gitea.io/gitea/modules/web"
@@ -888,7 +889,7 @@ func MergePullRequest(ctx *context.APIContext) {
888889
}
889890
defer headRepo.Close()
890891
}
891-
if pr.BaseRepoID == pr.HeadRepoID {
892+
if setting.Repository.PullRequest.RetargetChildsOnClose && pr.BaseRepoID == pr.HeadRepoID {
892893
if err := pull_service.RebaseBranchPulls(ctx, ctx.Doer, pr.HeadRepoID, pr.HeadBranch, pr.BaseBranch); err != nil {
893894
log.Error("RebaseBranchPulls: %v", err)
894895
ctx.Error(http.StatusInternalServerError, "RebaseBranchPulls", err)

routers/web/repo/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,7 @@ func CleanUpPullRequest(ctx *context.Context) {
13191319
func deleteBranch(ctx *context.Context, pr *models.PullRequest, gitRepo *git.Repository) {
13201320
fullBranchName := pr.HeadRepo.Owner.Name + "/" + pr.HeadBranch
13211321

1322-
if pr.BaseRepoID == pr.HeadRepoID {
1322+
if setting.Repository.PullRequest.RetargetChildsOnClose && pr.BaseRepoID == pr.HeadRepoID {
13231323
if err := pull_service.RebaseBranchPulls(ctx, ctx.Doer, pr.HeadRepoID, pr.HeadBranch, pr.BaseBranch); err != nil {
13241324
log.Error("RebaseBranchPulls: %v", err)
13251325
ctx.Flash.Error(ctx.Tr("repo.branch.deletion_failed", fullBranchName))

0 commit comments

Comments
 (0)