Skip to content

BBC2-23 add bb pr edit#23

Open
b2l wants to merge 1 commit into
mainfrom
bbc2-23-pr-edit
Open

BBC2-23 add bb pr edit#23
b2l wants to merge 1 commit into
mainfrom
bbc2-23-pr-edit

Conversation

@b2l
Copy link
Copy Markdown
Owner

@b2l b2l commented Apr 22, 2026

Summary

  • New bb pr edit [id] that updates a PR's title and/or description via PUT /pullrequests/{id}. Flags --title/-t and --description/-d. Defaults to the current branch's PR.
  • Without flags: opens $EDITOR with the current title on line 1, a blank separator, and the current description. First non-empty line on save becomes the title; everything after the first blank line is the description. Empty output aborts (no PUT).
  • No-op guard: only fields that actually differ from the PR's current state are PUT. --title "same as before" doesn't issue a request; the editor closed unchanged prints No changes to pull request #N.
  • Pre-flight GET refuses edits on MERGED, DECLINED, SUPERSEDED cleanly.
  • Sends partial bodies. The spec types the body as the full pullrequest schema but Bitbucket accepts partial bodies in practice (see docs/bb-notes.md → "Updating a PR"). If a future API change rejects them, the switch to GET-merge-PUT is local to the backend.
  • Reviewer editing is deliberately out of scope — blocked on BBC2-43's nickname → UUID resolution. Draft-state changes are out of scope too (BBC2-25 handles draft → ready one-way; reverse isn't supported by the API).

Test plan

  • bun test — 168 tests pass (5 new backend tests: title-only, description-only, both, 400 on closed PR, 404 on missing; 8 new unit tests for parseMessage covering happy path, multi-paragraph, trailing-only descriptions, leading blanks, extra separators, CRLF, empty input, trimming)
  • bun run lint clean
  • bunx tsc --noEmit clean
  • Manual: bb pr edit --help shows correct help

Manual test path

On a throwaway open PR (replace <N> with its id):

  1. bb pr edit <N> --title "Updated title" — title changes, description unchanged.
  2. bb pr edit <N> --description "Updated description" — description changes, title unchanged.
  3. bb pr edit <N> --title "T" --description "D" — both change in a single PUT.
  4. bb pr edit <N> --title "<exact current title>" — expect No changes to pull request #N., no API call.
  5. bb pr edit <N> — $EDITOR opens pre-filled with the existing title/description. Edit and save → PUT; close without changes → No changes to pull request #N.
  6. bb pr edit <N> → delete all content → save. Expect Edit aborted: title is empty.
  7. On a branch with an open PR: bb pr edit (no id) picks up the current-branch PR.
  8. Attempt bb pr edit <merged-or-declined-N> → expect Pull request #N is merged; cannot edit. (or declined).
  9. bb --json pr edit <N> --title "JSON" emits the full updated PR detail.

Closes BBC2-23.

Update a PR's title and/or description via PUT /pullrequests/{id}. Flags:
--title (-t), --description (-d). Defaults to the PR for the current
branch.

Without flags, opens $EDITOR pre-filled with the current title (line 1),
a blank line, and the current description. First non-empty line on save
becomes the title; everything after the first blank line is the
description (standard git-style parsing). Empty editor output aborts
without a PUT.

No-op guard: only sends fields that actually differ from the PR's current
state. `--title "unchanged"` does not issue a PUT; editor close with no
changes prints "No changes to pull request #N." and returns cleanly.

Reviewer editing is deliberately out of scope — blocked on BBC2-43's
nickname → UUID resolution. Draft-state changes are out of scope too
(BBC2-25 handles draft → ready one-way; reverse is not supported by the
API).

Sends partial bodies (just title/description). The spec's doc comment is
vague but Bitbucket accepts them in practice — see docs/bb-notes.md →
"Updating a PR". If a future API change rejects partial bodies we'd need
to switch to GET-merge-PUT; the backend test layout makes that easy to
land without touching the command.
@b2l b2l mentioned this pull request Apr 22, 2026
4 tasks
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