Skip to content

BBC2-17 add bb pr comment + extract body-input and current-PR helpers#15

Merged
b2l merged 1 commit into
mainfrom
b2lpowa/bbc2-17-comment-on-a-pull-request
Apr 15, 2026
Merged

BBC2-17 add bb pr comment + extract body-input and current-PR helpers#15
b2l merged 1 commit into
mainfrom
b2lpowa/bbc2-17-comment-on-a-pull-request

Conversation

@b2l
Copy link
Copy Markdown
Owner

@b2l b2l commented Apr 15, 2026

Summary

  • New bb pr comment [<id>] command. Posts a top-level comment on a PR; defaults to the PR for the current branch when no id is given.
  • Body input: --body "text", --body-file <path>, --body-file - (stdin), or drops into $EDITOR when none of the above are supplied. Empty body is rejected.
  • Output: the new comment's URL (from links.html.href on the 201 response).
  • Markup is set to markdown explicitly in the POST body.

Refactors (same PR — second-use extractions)

  • src/shared/editor/body-input.ts — shared --body/--body-file/stdin/editor resolver. bb pr create now uses it too, which incidentally ships stdin support for bb pr create (deferred in BBC2-10).
  • src/commands/pullrequest/current.ts — shared [<id>] vs. "PR for current branch" resolver with consistent error messages. bb pr view now uses it; bb pr comment uses it.

Each helper had a single inline use before — factored out now rather than when the third command arrives.

Smoke-test caveat (from docs/bb-notes.md)

The ticket flags: verify whether Bitbucket's implicit default for content.markup is already "markdown". We send it explicitly, which is safe either way. If the smoke test shows it's redundant we can drop it later — no blocker.

Test plan

  • bun src/index.ts pr comment --body "LGTM via bbcli" (on a branch with an open PR) posts the comment and prints its URL. Verify in the Bitbucket UI that it renders as markdown (try **bold** / a # heading to confirm).
  • bun src/index.ts pr comment <id> --body "explicit id" works when no open PR for the current branch.
  • echo "from stdin" | bun src/index.ts pr comment <id> --body-file - posts via stdin.
  • bun src/index.ts pr comment <id> with no flags opens $EDITOR. Save with content → posts. Save empty → exits with "Comment body is empty".
  • Migrated commands still work: bun src/index.ts pr view (auto-detect) and bun src/index.ts pr view <id>.
  • Migrated bb pr create --body-file - reads from stdin (the bonus side-effect of the extraction).
  • Tests: bun test — 138 passing (7 new: 3 backend, 4 body-input helper).
  • Lint: bun run lint.

Out of scope (explicit per ticket)

  • Inline / line-anchored comments → BBC2-22.
  • Replying to an existing comment.
  • Editing / deleting comments.

New command: bb pr comment [<id>] --body/--body-file/-. Defaults to the
open PR for the current branch when no id is supplied. Posts the raw
body as markdown (content.markup="markdown" is explicit — the server's
implicit default isn't documented, verifying via smoke test).

Extracts two helpers while we're here, since this is the second command
using each pattern:

- src/shared/editor/body-input.ts — resolves --body / --body-file / stdin
  (via --body-file -) / $EDITOR fallback in one place. bb pr create now
  uses it too, which incidentally unblocks BBC2-10's deferred stdin
  support.
- src/commands/pullrequest/current.ts — resolves [<id>] vs current-branch
  PR detection. bb pr view switches to it; bb pr comment uses it.
@b2l b2l merged commit 19ccdbd into main Apr 15, 2026
1 check passed
@b2l b2l deleted the b2lpowa/bbc2-17-comment-on-a-pull-request branch April 15, 2026 08:37
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