feat(branch-protection): force-push allowlist + admin override #36
No reviewers
Labels
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
codefloe/forgejo-codefloe!36
Loading…
Reference in a new issue
No description provided.
Delete branch "t3code/47e77305"
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
Allows repo admins and selected users/teams to force-push to a protected branch via a per-rule allowlist that mirrors the existing merge whitelist.
What changed
Adds an opt-in Enable force-push allowlist toggle to each branch protection rule.
When enabled, only listed users and teams can force-push.
Repo admins can also force-push when Enforce this rule for repository admins is off — the same admin-exemption flag used by other branch protection rules.
When a force-push is allowed via override, the git client sees a one-line note in the push output:
…or
(admin override)for the admin path.This uses a new general-purpose
Messageschannel on the private pre-receive hook response, so future "allowed but worth telling the user" cases can reuse it.Compatibility
Behavior is opt-in.
Existing protected branches default to
Enable force-push allowlist = false, which preserves the previous "force-push is always rejected" behavior.A forward-only migration adds three columns to the
protected_branchtable with safe defaults.Surface area
EnableForcePushAllowlist,ForcePushAllowlistUserIDs,ForcePushAllowlistTeamIDsfields plus migration; cleanup wired intoRemove{User,Team}IDFromProtectedBranchso removed users/teams are pruned from the lists.git_model.IsUserForcePushAllowlistedmirroringIsUserMergeWhitelisted.enable_force_push_allowlist,force_push_allowlist_usernames,force_push_allowlist_teamsonBranchProtection,CreateBranchProtectionOption, andEditBranchProtectionOption(plus swagger).Tests included
IsUserForcePushAllowlisted(toggle off, user listed, user not listed).Notes for reviewers
The first commit (
docs(superpowers): spec + plan …) adds design documentation underdocs/superpowers/.Drop or squash it before merge if you'd rather keep the design notes out of upstream.
Add Messages []string to Response and ResponseExtra, wire it through requestJSONResp, switch HookPreReceive client to decode JSON (Response{}) instead of plain text, switch the server-side success response to JSON, and print any messages to the git client output at both batch call sites.