Skip to content

fix(gh): skip compact_diff for --name-only/--stat in pr diff#773

Merged
aeppling merged 1 commit intortk-ai:developfrom
mvanhorn:osc/730-pr-diff-name-only-empty
Mar 22, 2026
Merged

fix(gh): skip compact_diff for --name-only/--stat in pr diff#773
aeppling merged 1 commit intortk-ai:developfrom
mvanhorn:osc/730-pr-diff-name-only-empty

Conversation

@mvanhorn
Copy link

Summary

  • Skip compact_diff filtering when gh pr diff is called with output-format-changing flags (--name-only, --stat, --name-status, --numstat, --shortstat)

Why this matters

compact_diff() expects unified diff format with diff --git headers and @@ hunks. When --name-only is 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 gh from the rtk hook entirely via config.toml.

Changes

Added has_non_diff_format_flag() in src/gh_cmd.rs that 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)
  • Unit tests for has_non_diff_format_flag with all 5 flag variants
  • Verified no-flag case still uses compact_diff path

Fixes #730

This contribution was developed with AI assistance (Claude Code).

@CLAassistant
Copy link

CLAassistant commented Mar 21, 2026

CLA assistant check
All committers have signed the CLA.

@pszymkowiak pszymkowiak added bug Something isn't working effort-small Quelques heures, 1 fichier filter-quality Filter produces incorrect/truncated signal labels Mar 21, 2026
@pszymkowiak
Copy link
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes empty output when gh pr diff is called with format-changing flags like --name-only or --stat. The compact_diff filter expects unified diff format, so these flags now trigger the passthrough path, skipping the filter entirely.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #730


Analyzed automatically by wshm · This is an automated analysis, not a human review.

@aeppling
Copy link
Contributor

#775 merged , can you rebase this please ?

@aeppling aeppling self-assigned this Mar 21, 2026
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>
@mvanhorn mvanhorn force-pushed the osc/730-pr-diff-name-only-empty branch from 069a3b7 to 2ef0690 Compare March 22, 2026 02:16
@mvanhorn
Copy link
Author

Rebased onto develop in 2ef0690.

@aeppling
Copy link
Contributor

Merging this to follow with #775 into next release

Thanks for your contributions @mvanhorn

@aeppling aeppling merged commit c576249 into rtk-ai:develop Mar 22, 2026
9 checks passed
@mvanhorn
Copy link
Author

Thanks for the fast turnaround on review and merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working effort-small Quelques heures, 1 fichier filter-quality Filter produces incorrect/truncated signal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants