Skip to content

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

Open
enoquefcd wants to merge 5 commits into
go-gitea:mainfrom
enoquefcd:feat/allow-protected-branch-deletion
Open

feat(repo): allow deleting protected branches#39243
enoquefcd wants to merge 5 commits into
go-gitea:mainfrom
enoquefcd:feat/allow-protected-branch-deletion

Conversation

@enoquefcd

Copy link
Copy Markdown

Protected branches currently cannot be deleted, preventing cleanup of release and feature branches after merge.

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; default branches remain undeletable. Deploy keys must also have normal push access.

Covered by model and migration tests, API user/team scenarios, and real SSH push tests for deploy-key allow/deny combinations. Manual reproduction and low-resource test runner: https://github.com/enoquefcd/gitea-protected-branch-deletion-demo

Closes #33305

Continues #37944 by @TIR44.

Protected branch deletion allowlists

Assisted-by: Codex:GPT-5

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 4, 2026
@github-actions github-actions Bot added topic/repo Related to repositories type/feature Completely new functionality. Can only be merged if feature freeze is not active. labels Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. topic/repo Related to repositories type/feature Completely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not possible to delete branch when a branch protection rule is matched

2 participants