feat(repo): allow deleting protected branches (#39243)

This adds a Branch Deletion setting with three modes: disabled by
default, anyone with push access, or a restricted user/team/deploy-key
allowlist. The policy applies to Git pushes, API/UI deletion, and
post-merge cleanup; the default branch and the pull request target
branch remain undeletable.

Closes https://github.com/go-gitea/gitea/issues/33305

---------

Co-authored-by: Enoque Duarte <12515551+enoquefcd@users.noreply.github.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
authored and GitHub committed 2026-10-14 07:19:49 +00:00
1 parent aebdbd85fb
commit b015cd67e2
21 files changed
+600 -59

No files matched your search

+9
View File
@@ -2299,6 +2299,7 @@
"repo.settings.event_release_desc": "Release published, updated or deleted in a repository.",
"repo.settings.event_push": "Push",
"repo.settings.event_force_push": "Force Push",
"repo.settings.event_branch_delete": "Branch Deletion",
"repo.settings.event_push_desc": "Git push to a repository.",
"repo.settings.event_repository": "Repository",
"repo.settings.event_repository_desc": "Repository created, deleted, or renamed.",
@@ -2410,6 +2411,12 @@
"repo.settings.protect_enable_force_push_all_desc": "Anyone with push access will be allowed to force push to this branch.",
"repo.settings.protect_enable_force_push_allowlist": "Allowlist Restricted Force Push",
"repo.settings.protect_enable_force_push_allowlist_desc": "Only allowlisted users or teams with push access will be allowed to force push to this branch.",
"repo.settings.protect_disable_deletion": "Disable Branch Deletion",
"repo.settings.protect_disable_deletion_desc": "No branch deletion will be allowed for this branch.",
"repo.settings.protect_enable_deletion_all": "Enable Branch Deletion",
"repo.settings.protect_enable_deletion_all_desc": "Anyone with push access will be allowed to delete this branch.",
"repo.settings.protect_enable_deletion_allowlist": "Allowlist Restricted Branch Deletion",
"repo.settings.protect_enable_deletion_allowlist_desc": "Only allowlisted users or teams with push access will be allowed to delete this branch.",
"repo.settings.protect_enable_merge": "Enable Merge",
"repo.settings.protect_enable_merge_desc": "Anyone with write access will be allowed to merge the pull requests into this branch.",
"repo.settings.protect_whitelist_committers": "Allowlist Restricted Push",
@@ -2420,6 +2427,8 @@
"repo.settings.protect_force_push_allowlist_users": "Allowlisted users for force pushing:",
"repo.settings.protect_force_push_allowlist_teams": "Allowlisted teams for force pushing:",
"repo.settings.protect_force_push_allowlist_deploy_keys": "Allowlist deploy keys with push access to force push.",
"repo.settings.protect_deletion_allowlist_users": "Allowlisted users for deleting:",
"repo.settings.protect_deletion_allowlist_teams": "Allowlisted teams for deleting:",
"repo.settings.protect_merge_whitelist_committers": "Enable Merge Allowlist",
"repo.settings.protect_merge_whitelist_committers_desc": "Allow only allowlisted users or teams to merge pull requests into this branch.",
"repo.settings.protect_merge_whitelist_users": "Allowlisted users for merging:",