feat: Add bypass allowlist for branch protection (#36514)

- Introduce a “Bypass Protection Allowlist” on branch rules
(users/teams) alongside admins, with BlockAdminMergeOverride
  still respected.
- Surface the allowlist in API (create/edit options, structs) and
settings UI; merge box now shows the red button +
  message for bypass-capable users.
- Apply bypass logic to merge checks and pre-receive so allowlisted
users can override unmet approvals/status checks/
  protected files when force-merging.
- Add migration for new columns, locale strings, and unit tests (bypass
helper; queue test tweak).

<img width="1069" height="218" alt="image"
src="https://github.com/user-attachments/assets/0b61bc2a-a27f-47f3-a923-613688008e65"
/>


Fixes #36476

---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Giteabot <teabot@gitea.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Codex GPT-5.3 <codex@openai.com>
Co-authored-by: GPT-5.2 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com>
This commit is contained in:
Nicolas
2026-05-16 14:23:42 +00:00
committed by GitHub
co-authored by silverwind Giteabot wxiaoguang Codex GPT-5.3 GPT-5.2 Cursor Claude
parent 54ff68b0a9
commit eb93981d45
23 changed files with 572 additions and 40 deletions
+54
View File
@@ -22666,6 +22666,20 @@
"type": "string",
"x-go-name": "BranchName"
},
"bypass_allowlist_teams": {
"type": "array",
"items": {
"type": "string"
},
"x-go-name": "BypassAllowlistTeams"
},
"bypass_allowlist_usernames": {
"type": "array",
"items": {
"type": "string"
},
"x-go-name": "BypassAllowlistUsernames"
},
"created_at": {
"type": "string",
"format": "date-time",
@@ -22679,6 +22693,10 @@
"type": "boolean",
"x-go-name": "EnableApprovalsWhitelist"
},
"enable_bypass_allowlist": {
"type": "boolean",
"x-go-name": "EnableBypassAllowlist"
},
"enable_force_push": {
"type": "boolean",
"x-go-name": "EnableForcePush"
@@ -23522,6 +23540,20 @@
"type": "string",
"x-go-name": "BranchName"
},
"bypass_allowlist_teams": {
"type": "array",
"items": {
"type": "string"
},
"x-go-name": "BypassAllowlistTeams"
},
"bypass_allowlist_usernames": {
"type": "array",
"items": {
"type": "string"
},
"x-go-name": "BypassAllowlistUsernames"
},
"dismiss_stale_approvals": {
"type": "boolean",
"x-go-name": "DismissStaleApprovals"
@@ -23530,6 +23562,10 @@
"type": "boolean",
"x-go-name": "EnableApprovalsWhitelist"
},
"enable_bypass_allowlist": {
"type": "boolean",
"x-go-name": "EnableBypassAllowlist"
},
"enable_force_push": {
"type": "boolean",
"x-go-name": "EnableForcePush"
@@ -24929,6 +24965,20 @@
"type": "boolean",
"x-go-name": "BlockOnRejectedReviews"
},
"bypass_allowlist_teams": {
"type": "array",
"items": {
"type": "string"
},
"x-go-name": "BypassAllowlistTeams"
},
"bypass_allowlist_usernames": {
"type": "array",
"items": {
"type": "string"
},
"x-go-name": "BypassAllowlistUsernames"
},
"dismiss_stale_approvals": {
"type": "boolean",
"x-go-name": "DismissStaleApprovals"
@@ -24937,6 +24987,10 @@
"type": "boolean",
"x-go-name": "EnableApprovalsWhitelist"
},
"enable_bypass_allowlist": {
"type": "boolean",
"x-go-name": "EnableBypassAllowlist"
},
"enable_force_push": {
"type": "boolean",
"x-go-name": "EnableForcePush"
+54
View File
@@ -2850,6 +2850,20 @@
"type": "string",
"x-go-name": "BranchName"
},
"bypass_allowlist_teams": {
"items": {
"type": "string"
},
"type": "array",
"x-go-name": "BypassAllowlistTeams"
},
"bypass_allowlist_usernames": {
"items": {
"type": "string"
},
"type": "array",
"x-go-name": "BypassAllowlistUsernames"
},
"created_at": {
"format": "date-time",
"type": "string",
@@ -2863,6 +2877,10 @@
"type": "boolean",
"x-go-name": "EnableApprovalsWhitelist"
},
"enable_bypass_allowlist": {
"type": "boolean",
"x-go-name": "EnableBypassAllowlist"
},
"enable_force_push": {
"type": "boolean",
"x-go-name": "EnableForcePush"
@@ -3724,6 +3742,20 @@
"type": "string",
"x-go-name": "BranchName"
},
"bypass_allowlist_teams": {
"items": {
"type": "string"
},
"type": "array",
"x-go-name": "BypassAllowlistTeams"
},
"bypass_allowlist_usernames": {
"items": {
"type": "string"
},
"type": "array",
"x-go-name": "BypassAllowlistUsernames"
},
"dismiss_stale_approvals": {
"type": "boolean",
"x-go-name": "DismissStaleApprovals"
@@ -3732,6 +3764,10 @@
"type": "boolean",
"x-go-name": "EnableApprovalsWhitelist"
},
"enable_bypass_allowlist": {
"type": "boolean",
"x-go-name": "EnableBypassAllowlist"
},
"enable_force_push": {
"type": "boolean",
"x-go-name": "EnableForcePush"
@@ -5100,6 +5136,20 @@
"type": "boolean",
"x-go-name": "BlockOnRejectedReviews"
},
"bypass_allowlist_teams": {
"items": {
"type": "string"
},
"type": "array",
"x-go-name": "BypassAllowlistTeams"
},
"bypass_allowlist_usernames": {
"items": {
"type": "string"
},
"type": "array",
"x-go-name": "BypassAllowlistUsernames"
},
"dismiss_stale_approvals": {
"type": "boolean",
"x-go-name": "DismissStaleApprovals"
@@ -5108,6 +5158,10 @@
"type": "boolean",
"x-go-name": "EnableApprovalsWhitelist"
},
"enable_bypass_allowlist": {
"type": "boolean",
"x-go-name": "EnableBypassAllowlist"
},
"enable_force_push": {
"type": "boolean",
"x-go-name": "EnableForcePush"