Allow configuring default PR base branch (fixes #36412)#36425
Allow configuring default PR base branch (fixes #36412)#36425wxiaoguang merged 32 commits intogo-gitea:mainfrom
Conversation
|
Is there a reason why "default" branch can't be used as PR base branch? |
|
The linked issue explains it a bit - the idea is to support a setup where you have main branch, staging branch and the dev ones and while the repository main is the first one from the list, the staging is the base one for PRs. |
Yeah, changing the default branch changes more than just PR targets. Plus, when the PR UI tries to load the diff between the "default" branch and the staging branch (which your team normally PRs to), it tends to get really laggy (making the workflow of PRing the staging branch rather tedious). |
|
it's in the title - #36412 |
Hmm, totally missed that. But still don't understand the details ... in that case, why not set
What else would it affect?
If the default branch is |
Because the default branch is the repo's canonical ref, not just "the default PR target". It affects what
Clone defaults, the repository home view/default ref in the UI, and integrations/automation that implicitly use the default branch (for example links that omit a ref, docs references, or CI setups that follow the default branch unless configured otherwise). Many repos also want the default branch to represent the stable/releasable line for external consumers and casual viewers.
It avoids the PR-base mismatch, but at the cost of making an integration branch the repo's canonical branch. A common workflow keeps A configurable default PR base branch solves the actual pain point: it reduces mistakes (accidentally opening PRs against |
|
Thank you for the clarification, it makes sense. |
Thanks for taking a look, glad the motivation makes sense. Just to confirm: this is fully opt-in (per-repo default PR base branch), so there’s no behavior change unless the setting is configured. The changes mostly wire that base through the existing PR entry points (compare links / recently pushed prompt), and add a small safety guard to avoid auto-deleting the configured base branch in same-repo PR cleanup. Do you have any concerns with the current approach, or would you like any adjustments (naming/UI wording, docs, tests, or the branch-cleanup guard behavior)? |
|
If we want to add an option for pull request ,it should be in the |
Signed-off-by: Louis <116039387+tototomate123@users.noreply.github.com>
Done - moved the setting into the PR |
Feel free to help to edit this PR and add necessary tests. |
@lunny if you don't have plan to make more changes to this PR, it can be merged as-is. I don't really see anything seriously wrong would happen (at the worst, a 404 page indicates the repo admin to update the PR target branch). You can also make improvements in following up PRs. By the way, your suggestion is still not complete, it fails a repo with no PR unit. So if you'd like to make more changes, it also needs tests with good coverage. |
|
How does the UI look for the new field? Is it acceptable looking on the repo settings page? |
I have done enough and it is acceptable to me. If you don't like it, you can do more. |
I'm just asking for a screenshot. |
|
@tototomate123 never raise pull request from a the default branch, these are hard to collaborate on. |
|
There is one UI issue: The dropdown cannot be cleared so the default value can not be restored once changed. |
|
It appears fomantic should support a |
|
Maybe we should just have a "Default Branch" instead of empty option. Then there is no strange UX with clearable dropdown. |
Do you have plan to make more changes? I see most "dropdown (select)" elements don't have the ability to "restore" after their values are changed, not only in Gitea, but in all desktop/web apps. |
|
@lunny @silverwind anything else to change? |
The error message is clear enough. You can check your repo's pull requests settings. If any one still have plans to improve, just edit directly or make changes in following up PRs. To me, these "problems" are quite trivial and I don't need such feature, so I won't spend more time on it. |
|
I will test this one more time soon, hold on a bit with the merge. |
silverwind
left a comment
There was a problem hiding this comment.
UI looks ok to me now. Maybe still wait on @lunny's approval before merge.
* giteaofficial/main: Refactor merge conan and container auth preserve actions taskID (go-gitea#36560) Fix assignee sidebar links and empty placeholder after go-gitea#32465 refactor (go-gitea#36559) Fix various version parsing problems (go-gitea#36553) Fix highlight diff result (go-gitea#36539) Refactor Nuget Auth to reuse Basic Auth Token Validation (go-gitea#36558) Update go dependencies (go-gitea#36548) Prevent navigation keys from triggering actions during IME composition (go-gitea#36540) Fix various mermaid bugs (go-gitea#36547) Add `elk` layout support to mermaid (go-gitea#36486) Allow configuring default PR base branch (fixes go-gitea#36412) (go-gitea#36425) [skip ci] Updated translations via Crowdin Color command/error logs in Actions log (go-gitea#36538) Add paging headers (go-gitea#36521) Fix issues filter dropdown showing empty label scope section (go-gitea#36535) [SECURITY] fix: Adjust the toolchain version (go-gitea#36537) Hide `add-matcher` and `remove-matcher` from actions job logs (go-gitea#36520) Improve timeline entries for WIP prefix changes in pull requests (go-gitea#36518)
…itea#36425) This adds a per-repository default PR base branch and wires it through PR entry points. It updates compare links and recently pushed branch prompts to respect the configured base branch, and prevents auto-merge cleanup from deleting the configured base branch on same-repo PRs. ## Behavior changes - New PR compare links on repo home/issue list and branch list honor the configured default PR base branch. - The "recently pushed new branches" prompt now compares against the configured base branch. - Auto-merge branch cleanup skips deleting the configured base branch (same-repo PRs only). --------- Signed-off-by: Louis <116039387+tototomate123@users.noreply.github.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: silverwind <me@silverwind.io>




Summary
This adds a per-repository default PR base branch and wires it through PR entry points. It updates compare links and recently pushed branch prompts to respect the configured base branch, and prevents auto-merge cleanup from deleting the configured base branch on same-repo PRs.
Behavior changes
Testing
Not run (local UI verification only).
Reviewer question: I added a guard in
services/repository/branch.go(DeleteBranchAfterMerge flow) to avoid auto-deleting the configured default PR base branch for same-repo PRs. Is that desired, or is branch protection expected to cover this?