diff options
author | Tim <tim@datenknoten.me> | 2024-10-23 06:39:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-23 12:39:43 +0800 |
commit | de2ad2e1b177ed1c3412761c54b28579f8ecbb00 (patch) | |
tree | a8124fa2c61116adfe96e41b89335202c2955b55 /routers/api/v1 | |
parent | 620f19610ef747412a9e4265c6b20fa560663f17 (diff) | |
download | gitea-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.go | 5 |
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) |