aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1
diff options
context:
space:
mode:
authorTim <tim@datenknoten.me>2024-10-23 06:39:43 +0200
committerGitHub <noreply@github.com>2024-10-23 12:39:43 +0800
commitde2ad2e1b177ed1c3412761c54b28579f8ecbb00 (patch)
treea8124fa2c61116adfe96e41b89335202c2955b55 /routers/api/v1
parent620f19610ef747412a9e4265c6b20fa560663f17 (diff)
downloadgitea-de2ad2e1b177ed1c3412761c54b28579f8ecbb00.tar.gz
gitea-de2ad2e1b177ed1c3412761c54b28579f8ecbb00.zip
Make admins adhere to branch protection rules (#32248)
This introduces a new flag `BlockAdminMergeOverride` on the branch protection rules that prevents admins/repo owners from bypassing branch protection rules and merging without approvals or failing status checks. Fixes #17131 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'routers/api/v1')
-rw-r--r--routers/api/v1/repo/branch.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go
index 63de4b8b6a..bb16858c81 100644
--- a/routers/api/v1/repo/branch.go
+++ b/routers/api/v1/repo/branch.go
@@ -642,6 +642,7 @@ func CreateBranchProtection(ctx *context.APIContext) {
ProtectedFilePatterns: form.ProtectedFilePatterns,
UnprotectedFilePatterns: form.UnprotectedFilePatterns,
BlockOnOutdatedBranch: form.BlockOnOutdatedBranch,
+ BlockAdminMergeOverride: form.BlockAdminMergeOverride,
}
err = git_model.UpdateProtectBranch(ctx, ctx.Repo.Repository, protectBranch, git_model.WhitelistOptions{
@@ -852,6 +853,10 @@ func EditBranchProtection(ctx *context.APIContext) {
protectBranch.BlockOnOutdatedBranch = *form.BlockOnOutdatedBranch
}
+ if form.BlockAdminMergeOverride != nil {
+ protectBranch.BlockAdminMergeOverride = *form.BlockAdminMergeOverride
+ }
+
var whitelistUsers, forcePushAllowlistUsers, mergeWhitelistUsers, approvalsWhitelistUsers []int64
if form.PushWhitelistUsernames != nil {
whitelistUsers, err = user_model.GetUserIDsByNames(ctx, form.PushWhitelistUsernames, false)