feat: Add default PR branch update style setting (#37410)

Adds repository-level settings for pull request branch updates so admins
can choose the default update method and disable merge or rebase
updates.

<img width="1025" height="158"
src="https://github.com/user-attachments/assets/d030973b-0ddd-4035-b04f-145c445084d7"
/>

---------

Co-authored-by: OpenAI Codex (GPT-5) <codex@openai.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Nicolas
2026-05-16 12:06:40 +02:00
committed by GitHub
parent 16189a68c4
commit 34fd3c9f06
20 changed files with 493 additions and 60 deletions
@@ -1,21 +1,21 @@
{{$data := $.MergeBoxData}}
{{$issueLink := $.IssueLink}}
<div class="tw-w-full flex-left-right">
<div class="flex-text-block">
{{svg "octicon-alert"}}
{{ctx.Locale.Tr "repo.pulls.outdated_with_base_branch"}}
</div>
{{if $data.UpdateAllowed}}
<div class="ui buttons" data-global-init="initRepoPullRequestUpdate">
<button class="ui button link-action" data-url="{{$issueLink}}/update">
{{ctx.Locale.Tr "repo.pulls.update_branch"}}
{{if $data.UpdatePrimaryAction}}
<div class="ui buttons"{{if $data.UpdateStyleOptions}} data-global-init="initRepoPullRequestUpdate"{{end}}>
<button class="ui button link-action" data-url="{{$data.UpdatePrimaryAction.URL}}">
{{$data.UpdatePrimaryAction.Text}}
</button>
{{if $data.UpdateByRebaseAllowed}}
{{if gt (len $data.UpdateStyleOptions) 1}}
<div class="ui dropdown icon button">
{{svg "octicon-triangle-down"}}
<div class="menu">
<a class="item selected" data-update-url="{{$issueLink}}/update">{{ctx.Locale.Tr "repo.pulls.update_branch"}}</a>
<a class="item" data-update-url="{{$issueLink}}/update?style=rebase">{{ctx.Locale.Tr "repo.pulls.update_branch_rebase"}}</a>
{{range $data.UpdateStyleOptions}}
<a class="item {{if .Selected}}selected{{end}}" data-update-url="{{.URL}}">{{.Text}}</a>
{{end}}
</div>
</div>
{{end}}
+25 -1
View File
@@ -617,10 +617,34 @@
</div>
<div class="field">
<div class="ui checkbox">
<input name="pulls_allow_rebase_update" type="checkbox" {{if or (not $pullRequestEnabled) ($prUnit.PullRequestsConfig.AllowRebaseUpdate)}}checked{{end}}>
<input name="pulls_allow_merge_update" type="checkbox" {{if $prUnit.PullRequestsConfig.AllowMergeUpdate}}checked{{end}}>
<label>{{ctx.Locale.Tr "repo.settings.pulls.allow_merge_update"}}</label>
</div>
</div>
<div class="field">
<div class="ui checkbox">
<input name="pulls_allow_rebase_update" type="checkbox" {{if $prUnit.PullRequestsConfig.AllowRebaseUpdate}}checked{{end}}>
<label>{{ctx.Locale.Tr "repo.settings.pulls.allow_rebase_update"}}</label>
</div>
</div>
<div class="field">
<label>{{ctx.Locale.Tr "repo.settings.pulls.default_update_style"}}</label>
<div class="ui dropdown selection">
<select name="pulls_default_update_style">
{{range .PullsDefaultUpdateStyleOptions}}
<option value="{{.Value}}" {{if .Selected}}selected{{end}}>{{.Text}}</option>
{{end}}
</select>{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="default text">
{{.PullsDefaultUpdateStyleText}}
</div>
<div class="menu">
{{range .PullsDefaultUpdateStyleOptions}}
<div class="item" data-value="{{.Value}}">{{.Text}}</div>
{{end}}
</div>
</div>
</div>
<div class="field">
<div class="ui checkbox">
<input name="default_delete_branch_after_merge" type="checkbox" {{if or (not $pullRequestEnabled) ($prUnit.PullRequestsConfig.DefaultDeleteBranchAfterMerge)}}checked{{end}}>
+18
View File
@@ -25451,6 +25451,11 @@
"type": "boolean",
"x-go-name": "AllowMerge"
},
"allow_merge_update": {
"description": "either `true` to allow updating pull request branch by merge, or `false` to prevent it.",
"type": "boolean",
"x-go-name": "AllowMergeUpdate"
},
"allow_rebase": {
"description": "either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging.",
"type": "boolean",
@@ -25501,6 +25506,11 @@
"type": "string",
"x-go-name": "DefaultMergeStyle"
},
"default_update_style": {
"description": "set to an update style to be used by this repository: \"merge\" or \"rebase\".",
"type": "string",
"x-go-name": "DefaultUpdateStyle"
},
"description": {
"description": "a short description of the repository.",
"type": "string",
@@ -28926,6 +28936,10 @@
"type": "boolean",
"x-go-name": "AllowMerge"
},
"allow_merge_update": {
"type": "boolean",
"x-go-name": "AllowMergeUpdate"
},
"allow_rebase": {
"type": "boolean",
"x-go-name": "AllowRebase"
@@ -28993,6 +29007,10 @@
"type": "string",
"x-go-name": "DefaultTargetBranch"
},
"default_update_style": {
"type": "string",
"x-go-name": "DefaultUpdateStyle"
},
"description": {
"type": "string",
"x-go-name": "Description"
+18
View File
@@ -5619,6 +5619,11 @@
"type": "boolean",
"x-go-name": "AllowMerge"
},
"allow_merge_update": {
"description": "either `true` to allow updating pull request branch by merge, or `false` to prevent it.",
"type": "boolean",
"x-go-name": "AllowMergeUpdate"
},
"allow_rebase": {
"description": "either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging.",
"type": "boolean",
@@ -5669,6 +5674,11 @@
"type": "string",
"x-go-name": "DefaultMergeStyle"
},
"default_update_style": {
"description": "set to an update style to be used by this repository: \"merge\" or \"rebase\".",
"type": "string",
"x-go-name": "DefaultUpdateStyle"
},
"description": {
"description": "a short description of the repository.",
"type": "string",
@@ -9115,6 +9125,10 @@
"type": "boolean",
"x-go-name": "AllowMerge"
},
"allow_merge_update": {
"type": "boolean",
"x-go-name": "AllowMergeUpdate"
},
"allow_rebase": {
"type": "boolean",
"x-go-name": "AllowRebase"
@@ -9184,6 +9198,10 @@
"type": "string",
"x-go-name": "DefaultTargetBranch"
},
"default_update_style": {
"type": "string",
"x-go-name": "DefaultUpdateStyle"
},
"description": {
"type": "string",
"x-go-name": "Description"