✨ feat: add --body-file support to PR review write actions - #34
Conversation
|
Self-reviewed the diff and PR description. @SigureMo Please review this PR when you have time. Thanks! |
--body-file support to PR review write actions
There was a problem hiding this comment.
Pull request overview
Adds --body-file (including stdin via -) support to PR review write commands so multi-line Markdown bodies can be provided safely without shell-escaping, aligning these commands with existing pr review-submit --body-file behavior.
Changes:
- Add mutually exclusive
--body/--body-fileflags forpr thread-reply,pr review-comment, andpr review-suggest. - Reuse shared body resolution logic so
--body-file -reads from standard input. - Extend CLI tests and README examples to cover file/stdin usage and suggestion body composition.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/gh_llm/commands/pr.py |
Adds --body-file flags and shared _resolve_body_argument() to load body from file/stdin across PR write commands. |
tests/test_cli.py |
Adds tests for --body-file (file + stdin), suggestion body composition, and mutual exclusion handling. |
README.md |
Documents --body-file workflows for thread replies, review comments, suggestions, and stdin piping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| raise AssertionError("expected argparse to reject --body with --body-file") | ||
|
|
||
| err = capsys.readouterr().err | ||
| assert "argument -F/--body-file: not allowed with argument --body" in err |
There was a problem hiding this comment.
This assertion depends on argparse’s exact error string, which can change between Python/argparse versions (or even reorder option names). To avoid brittle failures, assert more loosely (e.g., check for not allowed with argument and the presence of both --body and --body-file), rather than the full formatted message.
| assert "argument -F/--body-file: not allowed with argument --body" in err | |
| assert "not allowed with argument" in err | |
| assert "--body" in err | |
| assert "--body-file" in err |
ShigureNyako
left a comment
There was a problem hiding this comment.
结论:COMMENT(从代码质量判断,这个 PR 我会给出 APPROVE;但当前登录账号与 PR 作者相同,GitHub 不允许对自己的 PR 直接提交 APPROVE,因此这里用 COMMENT 形式提交正式 review。)
我独立检查了这次改动,重点看了功能设计、CLI 交互、一致性、边界行为、测试覆盖和文档。
结论依据:
- 功能设计:实现范围与 #20 对齐,只补齐
thread-reply/review-comment/review-suggest的--body-file,没有把 #28 的更大范围输入一致性改动混入当前 PR,scope 控制合理。 - CLI 交互与一致性:三个命令都统一为
--body/--body-file互斥;--body-file -复用了现有 stdin 读取语义,与review-submit保持一致。 - 边界行为:
review-suggest在未提供正文时仍回退到Suggested change,兼容现有默认行为,没有看到回归风险。 - 测试覆盖:新增了 file 输入、stdin 输入、suggestion 组合,以及互斥参数校验相关测试。
- 文档:README 已补充典型示例,并明确说明可通过
--body-file -从标准输入读取多行内容。
我还在本地基于该 PR 代码验证了:
uv run pytest -quv run ruff check .uv run pyright src/gh_llm testsprettier --check README.md
目前没有看到阻塞合并的问题。#28 中剩余的输入一致性补齐仍可作为后续独立工作继续推进。
Motivation
gh-llm pr review-submitalready supports--body-file, but the other PR review write commands still required inline--bodytext. That makes thread replies and inline review messages awkward for multi-line Markdown, quoted replies, and shell-safe automation.This PR closes that gap for issue #20 while keeping the scope limited to the three commands covered there, leaving the broader input-consistency follow-up in #28 unchanged.
Changes
--body/--body-fileinputs for:gh-llm pr thread-replygh-llm pr review-commentgh-llm pr review-suggest--body-file -reads from standard inputreview-suggestdefault behavior intact by falling back toSuggested changewhen no body input is providedREADME.mdValidation
uv run ruff format --check src/gh_llm/commands/pr.py tests/test_cli.pyuv run ruff check .uv run pyright src/gh_llm testsuv run pytest -qprettier --check README.mdRelated Issues