BBC2-16 add bb pr decline#21
Open
b2l wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bb pr decline [id]that declines an open PR viaPOST /pullrequests/{id}/decline. Defaults to the current branch's PR.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 aPullRequestErrorfrom the backend.--reason/--commentflag. Composition withbb pr commentkeeps 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 lintcleanbunx tsc --noEmitcleanbb pr decline --helpshows correct helpbb pr decline abcrejects bad ids (viaresolveCurrentPullRequestId)Manual test path
bb pr decline <N>→ expectDeclined pull request #<N>: <url>. Verify state in Bitbucket web UI.Pull request #<N> is declined; cannot decline.(no API call made — served from the pre-flight GET).bb pr decline <N>→ expectPull request #<N> is merged; cannot decline.bb pr decline(no id) → declines that PR.No open pull request for branch '<branch>'. Pass a PR number explicitly (bb pr decline <n>) or list available PRs (bb pr list).bb --json pr decline <N>emits the full declined PR detail object.Closes BBC2-16.