anvil pr diff <num> — print PR diff to stdout #11
Links
No links yet.
Problem
No way to print a PR’s diff from the CLI. Common use: pipe to `less`, AI tools, custom review scripts.
Proposal
`anvil pr diff ` prints the unified diff between PR base and head to stdout.
Implementation options:
- Fetch base + head from the remote, run local `git diff base..head`. No new server endpoint; relies on `anvil repo clone` setup or working git remote.
- New server endpoint `GET /api/v1/:org/:repo/pulls/:n.diff` returning the diff.
Option 1 is cheapest and good for the v1.
Acceptance criteria
- `anvil pr diff ` prints unified diff to stdout, exits 0
- Works in a repo cloned via `anvil repo clone`
- `–name-only` flag for just file list
- Errors gracefully if not in a repo cwd
Origin
CLI gap audit.
Implemented — shipped in commit 0430ea2 (“feat(cli): –json flag, pr diff/checkout, commit view, milestone create”), before the PR-per-change convention.
Verified on main: anvil pr diff <num> resolves the PR’s base/head, fetches both, and prints the three-dot diff (<remote>/<base>...<remote>/<head>) so the patch is against the merge-base. Acceptance criteria:
- prints unified diff to stdout, exits 0 ✅
--name-onlyflag ✅ (plus--remote, defaultorigin)- works in a cloned repo ✅
- errors when git can’t fetch (surfaces
git fetch <remote> <base> <head> failed) ✅
Also honours --json (the patch is captured and returned as a payload field rather than streamed), per #32.