FJ-30: Add fj repo branch-protection subcommands (list/view/create/edit/delete) #38
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/repo-branch-protection-FJ-30"
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
Implements FJ-30: adds
fj repo branch-protection list|view|create|edit|deleteto manage a repository's branch protection rules.What changed
crates/fj-core/src/repo.rs): thin async wrappers over theforgejo-apiendpoints following the existing repo-op pattern:list_branch_protections,get_branch_protection,create_branch_protection,edit_branch_protection,delete_branch_protection. No clap/crossterm/fluent deps added, so the MCP-reuse contract still holds.crates/fj/src/repo.rs): newBranchProtectionSubcommandenum wired asRepoCommand::BranchProtectionunder thebranch-protectionliteral (aliasbranch-protections), mirroring theLabelsSubcommandpattern. A flattenedBranchProtectionFlagsArgs struct exposes every field ofCreateBranchProtectionOption/EditBranchProtectionOptionas long-form flags; list-valued fields accept repeated flags, and an unset flag maps toNoneso the API leaves it unchanged.listandviewhonor the global--jsonflag via a stableBranchProtectionJsonprojection (mirrorsLabelJson).crates/fj/localization/en-US/messages.ftl): newmsg-repo-branch_protection-*strings for the success/empty messages.Rules are addressed by
rule_name(the API path parameter).branch_name(deprecated by the API) is exposed oncreateonly and defaults to the rule name when omitted.Acceptance criteria
cargo tree -p fj-client -p fj-core -e normal | grep -E 'clap|crossterm|fluent'stays emptybranch-protection listprints all rules;--jsonemits the projection structsbranch-protection view <rule_name>shows one rule;--jsonsupportedbranch-protection createaccepts long-form flags covering everyCreateBranchProtectionOptionfieldbranch-protection edit <rule_name>accepts the same flags (all optional), sending only set fieldsbranch-protection delete <rule_name>removes the ruleVerification
cargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo build --all-targets, andcargo testall pass; the MCP-contract grep is empty. CLI help for the new subcommands renders correctly.#FJ-30