fix(gh): skip compact_diff for --name-only/--stat in pr diff#773
Merged
aeppling merged 1 commit intortk-ai:developfrom Mar 22, 2026
Merged
Conversation
Collaborator
📊 Automated PR Analysis
SummaryFixes empty output when Review Checklist
Linked issues: #730 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
Contributor
|
#775 merged , can you rebase this please ? |
When `gh pr diff` is called with output-format-changing flags like --name-only, --stat, --name-status, --numstat, or --shortstat, the output is a plain filename/stat list rather than a unified diff. compact_diff() expects diff headers and hunks, so it produces empty output from these formats. Skip filtering and passthrough directly when any of these flags are present. The output is already compact and doesn't benefit from diff compaction. Fixes rtk-ai#730 Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
069a3b7 to
2ef0690
Compare
Author
|
Rebased onto develop in 2ef0690. |
Contributor
aeppling
approved these changes
Mar 22, 2026
Author
|
Thanks for the fast turnaround on review and merge! |
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
compact_difffiltering whengh pr diffis called with output-format-changing flags (--name-only,--stat,--name-status,--numstat,--shortstat)Why this matters
compact_diff()expects unified diff format withdiff --githeaders and@@hunks. When--name-onlyis passed, gh outputs a plain filename list that matches none of these patterns, producing empty output. Claude Code with the rtk hook sees empty output and concludes "no changed files" (#730).Same class of bug as #720 - a filter that doesn't account for a flag silently produces wrong output. @cderv works around both by excluding
ghfrom the rtk hook entirely viaconfig.toml.Changes
Added
has_non_diff_format_flag()insrc/gh_cmd.rsthat checks for flags producing non-unified-diff output. When any of these flags are present,pr_diff()now takes the early passthrough path (same as--no-compact), matching the existing pattern at line 1117-1118.7 unit tests cover all flag variants and the no-flag case.
Test plan
cargo fmt --all --check && cargo clippy --all-targets && cargo test(1079 tests pass)has_non_diff_format_flagwith all 5 flag variantscompact_diffpathFixes #730
This contribution was developed with AI assistance (Claude Code).