Skip to content

Commit 49da6e9

Browse files
committed
Add comments
1 parent 6838b29 commit 49da6e9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

routers/web/repo/editor.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ func canCreateBasePullRequest(ctx *context.Context) bool {
4545
return baseRepo != nil && baseRepo.UnitEnabled(ctx, unit.TypePullRequests)
4646
}
4747

48+
// defaultCreateNewBranch checks if the default commit choice should be to create new branch.
49+
// As a heuristic, always do this the default branch on forks, which is the right choice for
50+
// pull requests, and making further edits to that pull request branch.
4851
func defaultCreateNewBranch(ctx *context.Context) bool {
4952
baseRepo := ctx.Repo.Repository.BaseRepo
5053
return canCreateBasePullRequest(ctx) && baseRepo != nil && ctx.Repo.BranchName == baseRepo.DefaultBranch
@@ -69,6 +72,8 @@ func redirectForCommitChoice(ctx *context.Context, commitChoice, newBranchName,
6972
repo := ctx.Repo.Repository
7073
baseBranch := ctx.Repo.BranchName
7174
headBranch := newBranchName
75+
// Prefer to create a pull request to the base repository if possible, matching
76+
// the behavior when creating a pull request from a branch elsewhere in the UI.
7277
if canCreateBasePullRequest(ctx) {
7378
redirectToPullRequest = true
7479
baseBranch = repo.BaseRepo.DefaultBranch

0 commit comments

Comments
 (0)