feat: add pr merge and update-branch (task 0012) #12
Reference in New Issue
Block a user
Delete Branch "task-0012-pr-merge-and-update-branch"
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?
Task:
.claude/tasks/0012-pr-merge-and-update-branch.mdSummary
Adds two
prsubcommands:pr merge <n>— all six Gitea methods via--method, the three common-method shorthands (--merge/--squash/--rebase), plus--auto,--delete-branch,--subject,--body/--body-file, and--merge-commit-id. Conflicting/duplicate method flags and themanually-merged↔--merge-commit-idpairing are rejected asVALIDATION_ERRORbefore any API call. An already-merged PR short-circuits (no merge call) to apull_requestentity block carryingmerged_by/merged_at; a successful merge outputsmerged: { number, status: "ok", method }. Merge-blocked 405/409 responses surface asVALIDATION_ERRORwith the server's message plus remediation help lines.pr update-branch <n>— merges the base branch into the head via the update endpoint with--style <merge|rebase>(default merge), outputtingupdated: { number, status: "ok" }.Fixture-server tests cover each method, the shorthands, the local validations, the idempotent no-op, and the 405/409 mappings (24 new tests; full suite 301 green).
Deviations
Do: mergesent,method: defaultreported. Gitea's merge endpoint requires a concreteDo; the reported field describes the caller's (absent) choice, matching the gh-axi interface shape. Consequence: a squash-only repo will reject a barepr mergewith a 405 (surfaced with the server message). Respecting the repo'sdefault_merge_styleis a possible follow-up.--method+shorthand cases, rather than the interface doc's two separate strings.pr checkout <n>, which lands in task 0014 and does not exist yet.Review
Risk
Overall: Medium
src/commands/pr.tsplus two new test files; no existing callers touched.pr merge/update-branchare irreversible remote mutations; a wrong method or premature merge has real consequences.Unaddressed findings
Standards and Spec each surfaced only judgement calls; the one actionable Standards item (double
classifyHttpErrorcall in the 405/409 branch) was fixed in this diff. Remaining, left as-is:method ?? "default"mixes a magic string into themethod:enum field (judgement call). Deliberate and documented: it matches the gh-axi interface's reported shape and never reaches the wire as aDovalue.MERGE_SHORTHANDSas a record+loop for three fixed entries (judgement call). Kept: the map reads clearly as data and localizes the shorthand→method mapping.VALIDATION_ERRORbefore any API call, which holds; the combined message reads at least as clearly.