feat: add delete allowlist for branch protection rules (#696) #706
Reference in New Issue
Block a user
Delete Branch "feature/delete-whitelist"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Changes
models/git/protected_branch.go): 6 new fields (CanDelete, EnableDeleteAllowlist, DeleteAllowlistUserIDs/TeamIDs, DeleteAllowlistDeployKeys, DeleteAllowlistActionsUser),CanUserDelete()method, updated WhitelistOptions/removeIDsmodels/migrations/v1_27/v361.go): v361 adds delete allowlist columns to protected_branch tablemodules/structs/repo_branch.go): Delete allowlist fields in BranchProtection, Create, and Edit option structsrouters/private/hook_pre_receive.go): Replaced unconditional deletion block with CanUserDelete check (handles both deploy key and user scenarios)services/repository/branch.go): CanDeleteBranch now uses GetFirstMatchProtectedBranchRule + CanUserDelete instead of IsBranchProtectedrouters/api/v1/repo/branch.go): Create and Edit branch protection endpoints support delete allowlist user/team resolutionrouters/web/repo/setting/protected_branch.go): Form processing for delete allowlist radio buttons and user/team dropdownstemplates/repo/settings/protected_branch.tmpl): Delete allowlist UI section (none/all/whitelist radio pattern matching force-push)options/locale/locale_en-US.json): 12 new locale stringsservices/convert/convert.go): Model-to-API mapping for delete allowlist fieldsDesign decisions
CanUserDeleteis independent of push permission (unlikeCanUserForcePushwhich requiresCanUserPush)Test plan
https://claude.ai/code/session_011AAFzotGMf3ayvXhEmStCd