-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Allow configuring default PR base branch (fixes #36412) #36425
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
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
10047b6
Add default PR base branch support to repositories
tototomate123 e52f187
fmt: update repo struct
tototomate123 9d5b6b4
swagger: regenerate spec
tototomate123 668575e
gitcmd: enforce timeout cancellation
tototomate123 c026345
move default PR base branch setting into repo_unit config
tototomate123 8b7728b
Merge branch 'main' into main
tototomate123 32d1eee
gitcmt: fix timout test stdin setup
tototomate123 e7363d5
gitcmt: revert timeout test change and drop Wait goroutine
tototomate123 3647385
Merge branch 'go-gitea:main' into main
tototomate123 9ecc21c
fix: align PR base branch config naming and errors
tototomate123 79b1ac5
fix: update default PR base branch naming in templates
tototomate123 c035282
chore: regenerate swagger spec
tototomate123 1e7b108
refactor: rename PR base branch to target branch and switch API compa…
tototomate123 4712e38
Merge branch 'main' into main
tototomate123 c3dd9c0
chore: regenerate swagger spec
tototomate123 3046628
repo: drop default target branch existence validation
tototomate123 2399fcd
Merge branch 'main' into pr-target-branch
wxiaoguang 331e0e4
fix
wxiaoguang 01e9145
fix
wxiaoguang 76e26d7
fix
wxiaoguang 5c57ca2
fix
wxiaoguang 07a5dfb
Merge branch 'main' into main
wxiaoguang de1425e
add check for default target branch & default branch
wxiaoguang db7d65c
fix
wxiaoguang a774f28
fix text
wxiaoguang 6cb1f0f
Merge branch 'main' into main
wxiaoguang 3951856
update locale
silverwind 92f8ad3
improve dropdown
wxiaoguang 6de9452
add helper message on Branches page
wxiaoguang 85b2722
fix ui
wxiaoguang 1f3d282
Merge branch 'go-gitea:main' into main
tototomate123 d6ce3ee
Merge branch 'main' into main
wxiaoguang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Copyright 2026 The Gitea Authors. All rights reserved. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package repo | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "code.gitea.io/gitea/models/unit" | ||
| "code.gitea.io/gitea/modules/util" | ||
| ) | ||
|
|
||
| func (repo *Repository) GetPullRequestTargetBranch(ctx context.Context) string { | ||
| unitPRConfig := repo.MustGetUnit(ctx, unit.TypePullRequests).PullRequestsConfig() | ||
| return util.IfZero(unitPRConfig.DefaultTargetBranch, repo.DefaultBranch) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Copyright 2026 The Gitea Authors. All rights reserved. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package repo | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "code.gitea.io/gitea/models/unit" | ||
| "code.gitea.io/gitea/models/unittest" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestDefaultTargetBranchSelection(t *testing.T) { | ||
| assert.NoError(t, unittest.PrepareTestDatabase()) | ||
|
|
||
| ctx := t.Context() | ||
| repo := unittest.AssertExistsAndLoadBean(t, &Repository{ID: 1}) | ||
|
|
||
| assert.Equal(t, repo.DefaultBranch, repo.GetPullRequestTargetBranch(ctx)) | ||
|
|
||
| repo.Units = nil | ||
| prUnit, err := repo.GetUnit(ctx, unit.TypePullRequests) | ||
| assert.NoError(t, err) | ||
| prConfig := prUnit.PullRequestsConfig() | ||
| prConfig.DefaultTargetBranch = "branch2" | ||
| prUnit.Config = prConfig | ||
| assert.NoError(t, UpdateRepoUnit(ctx, prUnit)) | ||
| repo.Units = nil | ||
| assert.Equal(t, "branch2", repo.GetPullRequestTargetBranch(ctx)) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.