Skip to content

Commit 660b3d2

Browse files
committed
Make retarget optional, keep default behaviour without option
1 parent 795d8cb commit 660b3d2

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

modules/setting/repository.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ var (
8484
PopulateSquashCommentWithCommitMessages bool
8585
AddCoCommitterTrailers bool
8686
TestConflictingPatchesWithGitApply bool
87+
RetargetChildsOnClose bool
8788
} `ini:"repository.pull-request"`
8889

8990
// Issue Setting
@@ -207,6 +208,7 @@ var (
207208
PopulateSquashCommentWithCommitMessages bool
208209
AddCoCommitterTrailers bool
209210
TestConflictingPatchesWithGitApply bool
211+
RetargetChildsOnClose bool
210212
}{
211213
WorkInProgressPrefixes: []string{"WIP:", "[WIP]"},
212214
// Same as GitHub. See

routers/api/v1/repo/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ func MergePullRequest(ctx *context.APIContext) {
904904
}
905905
defer headRepo.Close()
906906
}
907-
if pr.BaseRepoID == pr.HeadRepoID {
907+
if setting.Repository.PullRequest.RetargetChildsOnClose && pr.BaseRepoID == pr.HeadRepoID {
908908
if err := pull_service.RebaseBranchPulls(ctx, ctx.Doer, pr.HeadRepoID, pr.HeadBranch, pr.BaseBranch); err != nil {
909909
log.Error("RebaseBranchPulls: %v", err)
910910
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
@@ -1400,7 +1400,7 @@ func CleanUpPullRequest(ctx *context.Context) {
14001400
func deleteBranch(ctx *context.Context, pr *issues_model.PullRequest, gitRepo *git.Repository) {
14011401
fullBranchName := pr.HeadRepo.FullName() + ":" + pr.HeadBranch
14021402

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

0 commit comments

Comments
 (0)