-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Retarget branches to next branch in chain, rather than defaultBranch #35464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,11 +27,13 @@ import ( | |
"code.gitea.io/gitea/modules/queue" | ||
repo_module "code.gitea.io/gitea/modules/repository" | ||
"code.gitea.io/gitea/modules/reqctx" | ||
"code.gitea.io/gitea/modules/setting" | ||
"code.gitea.io/gitea/modules/timeutil" | ||
"code.gitea.io/gitea/modules/util" | ||
webhook_module "code.gitea.io/gitea/modules/webhook" | ||
actions_service "code.gitea.io/gitea/services/actions" | ||
notify_service "code.gitea.io/gitea/services/notify" | ||
pull_service "code.gitea.io/gitea/services/pull" | ||
release_service "code.gitea.io/gitea/services/release" | ||
files_service "code.gitea.io/gitea/services/repository/files" | ||
|
||
|
@@ -538,6 +540,13 @@ func DeleteBranch(ctx context.Context, doer *user_model.User, repo *repo_model.R | |
} | ||
|
||
if err := db.WithTx(ctx, func(ctx context.Context) error { | ||
if pr != nil && setting.Repository.PullRequest.RetargetChildrenOnMerge { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand. I think something may have gone wrong in the diff viewer? This block was moved from Or am I missing something? |
||
if err := pull_service.RetargetBranchPulls(ctx, doer, repo.ID, branchName, pr.BaseBranch); err != nil { | ||
log.Error("retargetBranchPulls failed: %v", err) | ||
return err | ||
} | ||
} | ||
|
||
if !notExist { | ||
if err := git_model.AddDeletedBranch(ctx, repo.ID, branchName, doer.ID); err != nil { | ||
return err | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these pull requests are not handled, they will because a dead pull request because head branch deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @lunny, I think my comment is a bit unclear.
What I mean to say is: once we're here, we're not going to give PRs any special treatment due to RetargetChildrenOnMerge. Any branch that still has the toDelete branch as head, will be redirected to the default branch.
My comment was only meant to explain why we're not giving those PRs special treatment here.
I think it's best if I remove the last two lines of this comment. The reason I felt the need to explain here, was because this was the place where we used to handle RetargetChildrenOnMerge. Now that we handle it in the PR-merge code-path, there's no reason for anyone to expect us to handle it on generic branch close.
In summary: I think the code's behavior is what we want (retarget PRs to the default branch when the head branch is deleted), and this comment (line 673 and 674) is confusing and should be deleted. Do you agree?
PS Sorry for the double-post. I was logged in to the wrong account :(