release: branch protection delete allowlist (#696) #707

Merged
jmiller merged 7 commits from dev into main 2026-06-28 01:20:32 +00:00
Owner

Summary

  • Branch protection delete allowlist: configurable per-user/team/deploy-key allowlist for deleting protected branches (#696)
  • Migration v361 adds 6 new columns to protected_branch table
  • Full stack: model, pre-receive hook, branch service, API (create+edit), web UI, locale strings
  • Default permission: admin access (higher threshold than force-push's write access)

Changes (13 files, +345/-20)

  • models/git/protected_branch.go — 6 fields, CanUserDelete() method, whitelist options, removal helpers
  • models/migrations/v1_27/v361.go — migration v361
  • modules/structs/repo_branch.go — API struct fields (BranchProtection, Create, Edit)
  • routers/private/hook_pre_receive.go — delete check with early user resolution
  • services/repository/branch.goCanDeleteBranch uses allowlist-aware check
  • routers/api/v1/repo/branch.go — create/edit branch protection endpoints
  • routers/web/repo/setting/protected_branch.go — web form handler
  • templates/repo/settings/protected_branch.tmpl — UI section (none/all/allowlist radio)
  • services/convert/convert.go — model-to-API mapping
  • services/forms/repo_form.go — form struct fields
  • options/locale/locale_en-US.json — 12 locale strings

Test plan

  • Create branch protection with delete disabled (default) — verify branch cannot be deleted
  • Enable delete for "all" — verify admins can delete
  • Enable delete with allowlist — verify only allowlisted users/teams can delete
  • API: create/edit branch protection with delete allowlist fields
  • Web UI: settings page shows delete section with correct radio/dropdown behavior
  • Non-allowlisted users get 403 on delete via git push

https://claude.ai/code/session_011AAFzotGMf3ayvXhEmStCd

## Summary - Branch protection delete allowlist: configurable per-user/team/deploy-key allowlist for deleting protected branches (#696) - Migration v361 adds 6 new columns to protected_branch table - Full stack: model, pre-receive hook, branch service, API (create+edit), web UI, locale strings - Default permission: admin access (higher threshold than force-push's write access) ## Changes (13 files, +345/-20) - `models/git/protected_branch.go` — 6 fields, `CanUserDelete()` method, whitelist options, removal helpers - `models/migrations/v1_27/v361.go` — migration v361 - `modules/structs/repo_branch.go` — API struct fields (BranchProtection, Create, Edit) - `routers/private/hook_pre_receive.go` — delete check with early user resolution - `services/repository/branch.go` — `CanDeleteBranch` uses allowlist-aware check - `routers/api/v1/repo/branch.go` — create/edit branch protection endpoints - `routers/web/repo/setting/protected_branch.go` — web form handler - `templates/repo/settings/protected_branch.tmpl` — UI section (none/all/allowlist radio) - `services/convert/convert.go` — model-to-API mapping - `services/forms/repo_form.go` — form struct fields - `options/locale/locale_en-US.json` — 12 locale strings ## Test plan - [ ] Create branch protection with delete disabled (default) — verify branch cannot be deleted - [ ] Enable delete for "all" — verify admins can delete - [ ] Enable delete with allowlist — verify only allowlisted users/teams can delete - [ ] API: create/edit branch protection with delete allowlist fields - [ ] Web UI: settings page shows delete section with correct radio/dropdown behavior - [ ] Non-allowlisted users get 403 on delete via git push https://claude.ai/code/session_011AAFzotGMf3ayvXhEmStCd
jmiller added 7 commits 2026-06-28 01:18:08 +00:00
Merge pull request 'merge: sync main into dev' (#705) from main into dev
Universal: Auto Version Bump / Version Bump (push) Has been skipped
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Failing after 51s
Deploy MokoGitea (Dev) / Build & Deploy to Dev (push) Failing after 1m12s
46cbf6600a
feat: add delete allowlist for branch protection rules (#696)
Universal: Auto Version Bump / Version Bump (push) Successful in 12s
PR RC Release / Build RC Release (pull_request) Successful in 2s
Universal: PR Check / Branch Policy (pull_request) Successful in 1s
Universal: PR Check / Validate PR (pull_request) Failing after 13s
Universal: PR Check / Secret Scan (pull_request) Successful in 1m33s
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
4178e7f23e
Add configurable per-user/team/deploy-key allowlist for deleting
protected branches. Previously, protected branches could never be
deleted via git push. Now admins can configure deletion permissions
with the same granularity as force-push allowlists.

- 6 new model fields: CanDelete, EnableDeleteAllowlist, DeleteAllowlistUserIDs/TeamIDs, DeleteAllowlistDeployKeys, DeleteAllowlistActionsUser
- CanUserDelete() method with admin-level default (higher than push)
- Migration v361 adds columns to protected_branch table
- Pre-receive hook checks delete allowlist instead of unconditional block
- CanDeleteBranch service uses CanUserDelete instead of IsBranchProtected
- API create/edit endpoints support delete allowlist fields
- Web UI settings page with radio buttons and user/team dropdowns
- 12 new locale strings for the delete allowlist UI

Claude-Session: https://claude.ai/code/session_011AAFzotGMf3ayvXhEmStCd
fix: restore original whitespace alignment in convert.go
PR RC Release / Build RC Release (pull_request) Successful in 3s
Universal: PR Check / Branch Policy (pull_request) Successful in 3s
Universal: PR Check / Validate PR (pull_request) Failing after 9s
Universal: Auto Version Bump / Version Bump (push) Successful in 17s
Universal: PR Check / Secret Scan (pull_request) Successful in 1m7s
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
c47013edb0
Claude-Session: https://claude.ai/code/session_011AAFzotGMf3ayvXhEmStCd
fix: set protectBranch.Repo before CanUserDelete to avoid extra DB load
PR RC Release / Build RC Release (pull_request) Successful in 2s
Universal: PR Check / Branch Policy (pull_request) Successful in 2s
Universal: PR Check / Validate PR (pull_request) Failing after 9s
Universal: Auto Version Bump / Version Bump (push) Successful in 12s
Universal: PR Check / Secret Scan (pull_request) Successful in 1m8s
RC Revert / Rename rc/ back to dev/ (pull_request) Has been skipped
Branch Cleanup / Delete merged branch (pull_request) Successful in 2s
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
81d20e25bf
Claude-Session: https://claude.ai/code/session_011AAFzotGMf3ayvXhEmStCd
Merge pull request 'feat: add delete allowlist for branch protection rules (#696)' (#706) from feature/delete-whitelist into dev
Universal: Auto Version Bump / Version Bump (push) Has been skipped
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Failing after 1m20s
Deploy MokoGitea (Dev) / Build & Deploy to Dev (push) Failing after 1m26s
92cf6a8521
fix: remove duplicate cascade-dev.yml synced to top-level (belongs in custom/)
Generic: Repo Health / Access control (pull_request) Successful in 1s
Generic: Repo Health / Site Health (pull_request) Has been skipped
Deploy MokoGitea (Dev) / Build & Deploy to Dev (push) Failing after 1m21s
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Failing after 1m12s
Branch Cleanup / Delete merged branch (pull_request) Has been skipped
RC Revert / Rename rc/ back to dev/ (pull_request) Has been skipped
Universal: Build & Release / Promote to RC (pull_request) Has been skipped
Universal: Build & Release / Build & Release Pipeline (pull_request) Failing after 59s
Universal: Workflow Sync Trigger / Sync workflows to live repos (pull_request) Failing after 4m11s
Generic: Repo Health / Scripts governance (pull_request) Has been cancelled
Generic: Repo Health / Repository health (pull_request) Has been cancelled
Generic: Repo Health / Report: Scripts Governance (pull_request) Has been cancelled
Generic: Repo Health / Report: Repository Health (pull_request) Has been cancelled
Universal: Auto Version Bump / Version Bump (push) Successful in 13s
Universal: PR Check / Branch Policy (pull_request) Successful in 1s
PR RC Release / Build RC Release (pull_request) Successful in 2s
Universal: PR Check / Validate PR (pull_request) Failing after 9s
Generic: Project CI / Lint & Validate (pull_request) Successful in 33s
Universal: PR Check / Secret Scan (pull_request) Successful in 1m21s
Generic: Project CI / Tests (pull_request) Has been cancelled
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
d2a3827202
Claude-Session: https://claude.ai/code/session_011AAFzotGMf3ayvXhEmStCd
jmiller merged commit 8ffd2ffe18 into main 2026-06-28 01:20:32 +00:00
Sign in to join this conversation.