feat: first-class branch-protection command (list/get/set) instead of raw API #375

Closed
opened 2026-08-10 21:09:27 +00:00 by hexajon · 0 comments
hexajon commented 2026-08-10 21:09:27 +00:00 (Migrated from codeberg.org)

Right now there is no typed madtea surface for branch protection. To check or set a branch's protection I have to drop to madtea api (or the MCP api_call) against /repos/{owner}/{repo}/branch_protections and hand-write the JSON body.

That is the one place a routine repo-governance task still needs raw API calls. It comes up whenever I audit or roll out protection across an org: read each branch's current rule, then POST a matching rule with the right required status-check contexts. Get a context string wrong and main silently becomes unmergeable, so hand-writing the body is exactly where a typed, validated command would help most.

Proposal: a branch-protection command family (with the matching MCP tool):

  • list - the branch-protection rules on a repo
  • get <branch> - one rule, formatted
  • set <branch> - create/update: required status checks + contexts, block direct push, force-push toggle, required approvals, signed commits, etc.
  • delete <branch>

Nice-to-haves:

  • read the required-check contexts straight from the repo's workflow job names, so they don't have to be transcribed by hand
  • a --from <branch> (or --from <repo>) that copies one branch's rule shape onto another, adjusting the contexts to the target's own workflow

Covers the Gitea and Forgejo /repos/{owner}/{repo}/branch_protections endpoints.

Right now there is no typed madtea surface for branch protection. To check or set a branch's protection I have to drop to `madtea api` (or the MCP `api_call`) against `/repos/{owner}/{repo}/branch_protections` and hand-write the JSON body. That is the one place a routine repo-governance task still needs raw API calls. It comes up whenever I audit or roll out protection across an org: read each branch's current rule, then POST a matching rule with the right required status-check contexts. Get a context string wrong and `main` silently becomes unmergeable, so hand-writing the body is exactly where a typed, validated command would help most. Proposal: a branch-protection command family (with the matching MCP tool): - `list` - the branch-protection rules on a repo - `get <branch>` - one rule, formatted - `set <branch>` - create/update: required status checks + contexts, block direct push, force-push toggle, required approvals, signed commits, etc. - `delete <branch>` Nice-to-haves: - read the required-check contexts straight from the repo's workflow job names, so they don't have to be transcribed by hand - a `--from <branch>` (or `--from <repo>`) that copies one branch's rule shape onto another, adjusting the contexts to the target's own workflow Covers the Gitea and Forgejo `/repos/{owner}/{repo}/branch_protections` endpoints.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sixfold-space/madtea#375
No description provided.