Skip to content

BBC2-16 add bb pr decline#21

Open
b2l wants to merge 1 commit into
mainfrom
bbc2-16-pr-decline
Open

BBC2-16 add bb pr decline#21
b2l wants to merge 1 commit into
mainfrom
bbc2-16-pr-decline

Conversation

@b2l
Copy link
Copy Markdown
Owner

@b2l b2l commented Apr 22, 2026

Summary

  • New bb pr decline [id] that declines an open PR via POST /pullrequests/{id}/decline. Defaults to the current branch's PR.
  • Pre-flights with a GET /pullrequests/{id} so we can refuse cleanly on already-terminal states (MERGED, DECLINED, SUPERSEDED) with a precise message — no need to parse Bitbucket's 4xx error body. The narrow race window where state flips between the GET and POST still surfaces as a PullRequestError from the backend.
  • Deliberately no --reason / --comment flag. Composition with bb pr comment keeps the two verbs orthogonal; the ticket called this out explicitly.

Test plan

  • bun test — 158 tests pass (3 new backend tests: happy path, terminal-state 4xx, 404)
  • bun run lint clean
  • bunx tsc --noEmit clean
  • Manual: bb pr decline --help shows correct help
  • Manual: bb pr decline abc rejects bad ids (via resolveCurrentPullRequestId)

Manual test path

  1. Open a throwaway PR against a real repo (or pick one you don't mind declining). Note its id and URL.
  2. bb pr decline <N> → expect Declined pull request #<N>: <url>. Verify state in Bitbucket web UI.
  3. Run the same command again → expect Pull request #<N> is declined; cannot decline. (no API call made — served from the pre-flight GET).
  4. Pick a merged PR and run bb pr decline <N> → expect Pull request #<N> is merged; cannot decline.
  5. On a branch that has an open PR: bb pr decline (no id) → declines that PR.
  6. On a branch without an open PR: expect No open pull request for branch '<branch>'. Pass a PR number explicitly (bb pr decline <n>) or list available PRs (bb pr list).
  7. bb --json pr decline <N> emits the full declined PR detail object.

Closes BBC2-16.

Declines an open PR via POST /pullrequests/{id}/decline. Defaults to the
PR for the current branch.

Pre-flights with a GET so we can refuse cleanly on already-terminal states
(MERGED / DECLINED / SUPERSEDED) with a precise message, without having to
parse Bitbucket's 4xx error body shape. The race case where the state flips
between the GET and POST still propagates as a PullRequestError from the
backend — rare in practice.

No --reason / --comment flag, as decided in the ticket: composition with
`bb pr comment` keeps the two verbs orthogonal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant