aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2023-02-13 07:09:52 +0100
committerGitHub <noreply@github.com>2023-02-13 14:09:52 +0800
commit49919c636e4788a14f3762a0d9137ee2e0092790 (patch)
treeacac92af0eff851eaea32416e17001ba0776032c /routers
parentb6d77229cfbab146da6445467acab2125e9e5edb (diff)
downloadgitea-49919c636e4788a14f3762a0d9137ee2e0092790.tar.gz
gitea-49919c636e4788a14f3762a0d9137ee2e0092790.zip
Pull Requests: setting to allow edits by maintainers by default, tweak UI (#22862)
Add setting to allow edits by maintainers by default, to avoid having to often ask contributors to enable this. This also reorganizes the pull request settings UI to improve clarity. It was unclear which checkbox options were there to control available merge styles and which merge styles they correspond to. Now there is a "Merge Styles" label followed by the merge style options with the same name as in other menus. The remaining checkboxes were moved to the bottom, ordered rougly by typical order of operations. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/repo.go4
-rw-r--r--routers/web/repo/compare.go7
-rw-r--r--routers/web/repo/setting.go1
3 files changed, 12 insertions, 0 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index 1426d1dbcc..f5db45ffea 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -863,6 +863,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
AllowRebaseUpdate: true,
DefaultDeleteBranchAfterMerge: false,
DefaultMergeStyle: repo_model.MergeStyleMerge,
+ DefaultAllowMaintainerEdit: false,
}
} else {
config = unit.PullRequestsConfig()
@@ -898,6 +899,9 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
if opts.DefaultMergeStyle != nil {
config.DefaultMergeStyle = repo_model.MergeStyle(*opts.DefaultMergeStyle)
}
+ if opts.DefaultAllowMaintainerEdit != nil {
+ config.DefaultAllowMaintainerEdit = *opts.DefaultAllowMaintainerEdit
+ }
units = append(units, repo_model.RepoUnit{
RepoID: repo.ID,
diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go
index c4b8c814e6..5b6faf4d83 100644
--- a/routers/web/repo/compare.go
+++ b/routers/web/repo/compare.go
@@ -820,6 +820,13 @@ func CompareDiff(ctx *context.Context) {
ctx.Data["HasIssuesOrPullsWritePermission"] = ctx.Repo.CanWrite(unit.TypePullRequests)
+ if unit, err := ctx.Repo.Repository.GetUnit(ctx, unit.TypePullRequests); err == nil {
+ config := unit.PullRequestsConfig()
+ ctx.Data["AllowMaintainerEdit"] = config.DefaultAllowMaintainerEdit
+ } else {
+ ctx.Data["AllowMaintainerEdit"] = false
+ }
+
ctx.HTML(http.StatusOK, tplCompare)
}
diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go
index 5c30795f22..436438c436 100644
--- a/routers/web/repo/setting.go
+++ b/routers/web/repo/setting.go
@@ -529,6 +529,7 @@ func SettingsPost(ctx *context.Context) {
AllowRebaseUpdate: form.PullsAllowRebaseUpdate,
DefaultDeleteBranchAfterMerge: form.DefaultDeleteBranchAfterMerge,
DefaultMergeStyle: repo_model.MergeStyle(form.PullsDefaultMergeStyle),
+ DefaultAllowMaintainerEdit: form.DefaultAllowMaintainerEdit,
},
})
} else if !unit_model.TypePullRequests.UnitGlobalDisabled() {