feat: implement branch protection rules #2
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
Context
Branch protection rules prevent direct pushes to protected branches, enforce code review,
and require CI to pass. Essential for any repository with a development workflow.
Endpoints to implement
/repos/{owner}/{repo}/branch_protectionslist_branch_protections/repos/{owner}/{repo}/branch_protectionscreate_branch_protection/repos/{owner}/{repo}/branch_protections/{name}get_branch_protection/repos/{owner}/{repo}/branch_protections/{name}edit_branch_protection/repos/{owner}/{repo}/branch_protections/{name}delete_branch_protectionAcceptance Criteria
list_branch_protections(owner, repo)returns all rulescreate_branch_protection(owner, repo, branch_name, ...)creates rule; key params:required_approvals,enable_push,require_signed_commitsget_branch_protection(owner, repo, name)fetches single rule by branch name patternedit_branch_protection(owner, repo, name, ...)updates rule fields via PATCHdelete_branch_protection(owner, repo, name)removes rule, returns{"success": true}_b()helperTechnical Notes
namefield is the branch name pattern (e.g.main,release/*)create/editbody fields:branch_name,enable_push,enable_push_whitelist,push_whitelist_usernames,required_approvals,enable_approvals_whitelist,approvals_whitelist_usernames,require_signed_commits,block_on_outdated_branch_strip()to omit unset optional fields