summaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorGeorge Bartolomey <george@bh4.ru>2024-12-14 08:12:04 +0100
committerGeorge Bartolomey <george@bh4.ru>2024-12-23 16:55:25 +0100
commit13ca6c14f16cf2f76243f5fd1bb7efb763de8a36 (patch)
tree689974045bd95e3d3ea4c6e432072bea806c89e9 /templates
parentMerge pull request 'Update module google.golang.org/grpc to v1.69.2 (forgejo)... (diff)
downloadforgejo-13ca6c14f16cf2f76243f5fd1bb7efb763de8a36.tar.xz
forgejo-13ca6c14f16cf2f76243f5fd1bb7efb763de8a36.zip
feat: allow changing default branch update style
This commit allows chaning default branch update style through global and repository settings. The setting affects "Update branch" button in PR view (button shows when some commits are ahead of master branch). When default update style is set to "rebase", dropdown button updates branch by rebase by default. When update style is set to other value, dropdown button updates branch by merge. Any of these actions may be selected using dropdown in any case. Signed-off-by: George Bartolomey <george@bh4.ru>
Diffstat (limited to 'templates')
-rw-r--r--templates/repo/issue/view_content/update_branch_by_merge.tmpl18
-rw-r--r--templates/repo/settings/units/pulls.tmpl23
-rw-r--r--templates/swagger/v1_json.tmpl9
3 files changed, 45 insertions, 5 deletions
diff --git a/templates/repo/issue/view_content/update_branch_by_merge.tmpl b/templates/repo/issue/view_content/update_branch_by_merge.tmpl
index adce052dee..9fbc8b018b 100644
--- a/templates/repo/issue/view_content/update_branch_by_merge.tmpl
+++ b/templates/repo/issue/view_content/update_branch_by_merge.tmpl
@@ -9,23 +9,31 @@
{{if and $.UpdateAllowed $.UpdateByRebaseAllowed}}
<div class="tw-inline-block">
<div class="ui buttons update-button">
- <button class="ui button" data-do="{{$.Link}}/update" data-redirect="{{$.Link}}">
+ <button class="ui button" data-do="{{$.Link}}/update?style={{$.UpdateStyle}}" data-redirect="{{$.Link}}">
<span class="button-text">
- {{ctx.Locale.Tr "repo.pulls.update_branch"}}
+ {{if eq $.UpdateStyle "rebase"}}
+ {{ctx.Locale.Tr "repo.pulls.update_branch_rebase"}}
+ {{else}}
+ {{ctx.Locale.Tr "repo.pulls.update_branch"}}
+ {{end}}
</span>
</button>
<div class="ui dropdown icon button">
{{svg "octicon-triangle-down"}}
<div class="menu">
- <a class="item active selected" data-do="{{$.Link}}/update">{{ctx.Locale.Tr "repo.pulls.update_branch"}}</a>
- <a class="item" data-do="{{$.Link}}/update?style=rebase">{{ctx.Locale.Tr "repo.pulls.update_branch_rebase"}}</a>
+ <a class="item {{if ne $.UpdateStyle "rebase"}}active selected{{end}}" data-do="{{$.Link}}/update?style=merge">
+ {{ctx.Locale.Tr "repo.pulls.update_branch"}}
+ </a>
+ <a class="item {{if eq $.UpdateStyle "rebase"}}active selected{{end}}" data-do="{{$.Link}}/update?style=rebase">
+ {{ctx.Locale.Tr "repo.pulls.update_branch_rebase"}}
+ </a>
</div>
</div>
</div>
</div>
{{end}}
{{if and $.UpdateAllowed (not $.UpdateByRebaseAllowed)}}
- <form action="{{$.Link}}/update" method="post" class="ui update-branch-form">
+ <form action="{{$.Link}}/update?style=merge" method="post" class="ui update-branch-form">
{{$.CsrfTokenHtml}}
<button class="ui compact button">
<span class="ui text">{{ctx.Locale.Tr "repo.pulls.update_branch"}}</span>
diff --git a/templates/repo/settings/units/pulls.tmpl b/templates/repo/settings/units/pulls.tmpl
index 4e9c53e0f4..2e637d4e0b 100644
--- a/templates/repo/settings/units/pulls.tmpl
+++ b/templates/repo/settings/units/pulls.tmpl
@@ -106,6 +106,29 @@
</div>
</div>
<div class="field">
+ <p>
+ {{ctx.Locale.Tr "repo.settings.default_update_style_desc"}}
+ </p>
+ <div class="ui dropdown selection">
+ <select name="pulls_default_update_style">
+ <option value="merge" {{if or (not $pullRequestEnabled) (eq $prUnit.PullRequestsConfig.DefaultUpdateStyle "merge")}}selected{{end}}>{{ctx.Locale.Tr "repo.pulls.update_branch"}}</option>
+ <option value="rebase" {{if or (not $pullRequestEnabled) (eq $prUnit.PullRequestsConfig.DefaultUpdateStyle "rebase")}}selected{{end}}>{{ctx.Locale.Tr "repo.pulls.update_branch_rebase"}}</option>
+ </select>{{svg "octicon-triangle-down" 14 "dropdown icon"}}
+ <div class="default text">
+ {{if (eq $prUnit.PullRequestsConfig.DefaultUpdateStyle "merge")}}
+ {{ctx.Locale.Tr "repo.pulls.update_branch"}}
+ {{end}}
+ {{if (eq $prUnit.PullRequestsConfig.DefaultUpdateStyle "rebase")}}
+ {{ctx.Locale.Tr "repo.pulls.update_branch_rebase"}}
+ {{end}}
+ </div>
+ <div class="menu">
+ <div class="item" data-value="merge">{{ctx.Locale.Tr "repo.pulls.update_branch"}}</div>
+ <div class="item" data-value="rebase">{{ctx.Locale.Tr "repo.pulls.update_branch_rebase"}}</div>
+ </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}}>
<label>{{ctx.Locale.Tr "repo.settings.pulls.default_delete_branch_after_merge"}}</label>
diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl
index f0a0b86622..1feeebba98 100644
--- a/templates/swagger/v1_json.tmpl
+++ b/templates/swagger/v1_json.tmpl
@@ -23321,6 +23321,11 @@
"type": "string",
"x-go-name": "DefaultMergeStyle"
},
+ "default_update_style": {
+ "description": "set to a update style to be used by this repository: \"rebase\" or \"merge\"",
+ "type": "string",
+ "x-go-name": "DefaultUpdateStyle"
+ },
"description": {
"description": "a short description of the repository.",
"type": "string",
@@ -26605,6 +26610,10 @@
"type": "string",
"x-go-name": "DefaultMergeStyle"
},
+ "default_update_style": {
+ "type": "string",
+ "x-go-name": "DefaultUpdateStyle"
+ },
"description": {
"type": "string",
"x-go-name": "Description"