BBC2-17 add bb pr comment + extract body-input and current-PR helpers#15
Merged
Merged
Conversation
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.
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 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 "text",--body-file <path>,--body-file -(stdin), or drops into$EDITORwhen none of the above are supplied. Empty body is rejected.links.html.hrefon the 201 response).markdownexplicitly 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 createnow uses it too, which incidentally ships stdin support forbb 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 viewnow uses it;bb pr commentuses 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.markupis 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# headingto 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".bun src/index.ts pr view(auto-detect) andbun src/index.ts pr view <id>.bb pr create --body-file -reads from stdin (the bonus side-effect of the extraction).bun test— 138 passing (7 new: 3 backend, 4 body-input helper).bun run lint.Out of scope (explicit per ticket)