Skip to content

✨ feat: add --body-file support to PR review write actions - #34

Merged
SigureMo merged 1 commit into
ShigureLab:mainfrom
ShigureNyako:feat/review-action-body-file-support
Mar 21, 2026
Merged

✨ feat: add --body-file support to PR review write actions#34
SigureMo merged 1 commit into
ShigureLab:mainfrom
ShigureNyako:feat/review-action-body-file-support

Conversation

@ShigureNyako

Copy link
Copy Markdown
Member

Motivation

gh-llm pr review-submit already supports --body-file, but the other PR review write commands still required inline --body text. 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

  • add mutually exclusive --body / --body-file inputs for:
    • gh-llm pr thread-reply
    • gh-llm pr review-comment
    • gh-llm pr review-suggest
  • reuse the existing file/stdin loading behavior so --body-file - reads from standard input
  • keep review-suggest default behavior intact by falling back to Suggested change when no body input is provided
  • document the new file/stdin workflow in README.md
  • add CLI tests covering file input, stdin input, suggestion-body composition, and mutual-exclusion validation

Validation

  • uv run ruff format --check src/gh_llm/commands/pr.py tests/test_cli.py
  • uv run ruff check .
  • uv run pyright src/gh_llm tests
  • uv run pytest -q
  • prettier --check README.md

Related Issues

@ShigureNyako

Copy link
Copy Markdown
Member Author

Self-reviewed the diff and PR description.

@SigureMo Please review this PR when you have time. Thanks!

@SigureMo
SigureMo requested a review from Copilot March 21, 2026 17:52
@SigureMo SigureMo changed the title ✨ feat: add --body-file support to PR review write actions ✨ feat: add --body-file support to PR review write actions Mar 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-file flags for pr thread-reply, pr review-comment, and pr 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.

Comment thread tests/test_cli.py
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

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.

@ShigureNyako ShigureNyako left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

结论: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 -q
  • uv run ruff check .
  • uv run pyright src/gh_llm tests
  • prettier --check README.md

目前没有看到阻塞合并的问题。#28 中剩余的输入一致性补齐仍可作为后续独立工作继续推进。

@SigureMo SigureMo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMeow 🐾

@SigureMo
SigureMo merged commit d5e4654 into ShigureLab:main Mar 21, 2026
6 checks passed
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.

feat: 为 thread-reply / review-comment / review-suggest 增加 --body-file 支持

3 participants