Add pr list and pr merge commands #4

Merged
daniel merged 1 commit from pr-merge into main 2026-11-21 11:24:42 +00:00
Collaborator

Adds two commands:

  • fgj pr list: lists pull requests, open ones by default. Filters: --state open|closed|merged|all, --author, --label (repeatable), --milestone, --sort. Also has --limit (default 30, 0 = all) and --json.
  • fgj pr merge [NUMBER]: merges a PR, or the open PR for the current branch.
    • Defaults to the repository's merge style and "delete branch after merge" setting. Styles the repository doesn't allow are rejected before anything is sent.
    • Sends the head commit it saw (head_commit_id), so a push in the meantime makes the merge fail with head out of date.
    • --auto merges once checks pass (v15 answers 201 when it schedules and 200 when it merges at once), and --cancel-auto cancels.
    • Asks for confirmation in an interactive terminal unless --yes is passed.

Found on the real server: once a PR's head branch is deleted, v15 reports head.ref as refs/pull/N/head. Branch names are now read from head.label.

Testing

  • New end-to-end tests run against a stateful fake that sends v15's merge responses and rejects any request field not in the v15 schema.
  • pr list was run against git.markow.dev and shows PRs #1–#3 with the correct branches.
  • pr merge was checked against git.markow.dev only for its refusals (already-merged PR, branch without a PR). A real merge hasn't been run yet; merging this PR with fgj pr merge would be the first.
  • README, auth login --help scopes and AGENTS.md are updated.

🤖 Generated with Claude Code

Adds two commands: - **`fgj pr list`**: lists pull requests, open ones by default. Filters: `--state open|closed|merged|all`, `--author`, `--label` (repeatable), `--milestone`, `--sort`. Also has `--limit` (default 30, `0` = all) and `--json`. - **`fgj pr merge [NUMBER]`**: merges a PR, or the open PR for the current branch. - Defaults to the repository's merge style and "delete branch after merge" setting. Styles the repository doesn't allow are rejected before anything is sent. - Sends the head commit it saw (`head_commit_id`), so a push in the meantime makes the merge fail with `head out of date`. - `--auto` merges once checks pass (v15 answers 201 when it schedules and 200 when it merges at once), and `--cancel-auto` cancels. - Asks for confirmation in an interactive terminal unless `--yes` is passed. **Found on the real server:** once a PR's head branch is deleted, v15 reports `head.ref` as `refs/pull/N/head`. Branch names are now read from `head.label`. **Testing** - New end-to-end tests run against a stateful fake that sends v15's merge responses and rejects any request field not in the v15 schema. - `pr list` was run against git.markow.dev and shows PRs #1–#3 with the correct branches. - `pr merge` was checked against git.markow.dev only for its refusals (already-merged PR, branch without a PR). A real merge hasn't been run yet; merging this PR with `fgj pr merge` would be the first. - README, `auth login --help` scopes and `AGENTS.md` are updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`fgj pr list` lists a repository's pull requests with state (open,
closed, merged, all), author, label, milestone and sort filters, a
--limit, and --json output.

`fgj pr merge [NUMBER]` merges a pull request, or the open PR for the
current branch. It defaults to the repository's merge style and
delete-branch setting, rejects styles the repository doesn't allow, and
sends the head commit it saw so a concurrent push makes the merge fail
instead of merging unseen commits. --auto schedules a merge for when
checks pass (and --cancel-auto undoes it); interactive terminals get a
confirmation prompt unless --yes is passed.

Forgejo v15 reports head.ref as refs/pull/N/head once the head branch is
deleted, so branch names are taken from head.label instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
daniel merged commit a323861223 into main 2026-11-21 11:24:42 +00:00
daniel deleted branch pr-merge 2026-11-21 11:24:47 +00:00
Sign in to join this conversation.
No reviewers
No labels
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
daniel/Forgejo-CLI!4
No description provided.