Skip to content

fix: ask gh for an uncolored PR diff - #92

Merged
brentvatne merged 1 commit into
mainfrom
@brent/gh-pr-diff-no-color
Oct 23, 2026
Merged

brentvatne merged 1 commit into
mainfrom
@brent/gh-pr-diff-no-color

Conversation

@brentvatne

Copy link
Copy Markdown
Member

Why

gh pr diff colors its output even into a pipe when the environment forces color (CLICOLOR_FORCE=1 or GH_FORCE_TTY=1). The escape codes in front of each diff --git line mean parseUnifiedDiff finds no files, so a CI review reports "No reviewable changes" and reviews nothing.

What

Pass --color never in both places that read the PR diff:

  • GitHubPRSource.getChangedFiles (src/sources/github-pr.ts), which builds the review's file list;
  • GitHubReporter.linkContextAsync (src/reporters/github.ts), which builds the diff-line index for inline links. Colored output there quietly downgraded in-diff findings to plain text.

Tests

src/__tests__/github-pr-diff.test.ts puts a fake gh on PATH that wraps every line in escape codes unless --color never is passed, then checks both callers parse the file and its lines. Both tests fail with the flag removed. The full suite, typecheck, lint, format and llp:check pass.

🤖 Generated with Claude Code

gh colors `gh pr diff` even into a pipe when CLICOLOR_FORCE or GH_FORCE_TTY
is set. The escape codes before each `diff --git` made the whole PR parse as
no files, so a CI review reported "No reviewable changes". Pass
`--color never` in both places that read the PR diff.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🤖 AI code review

Decision: Ready for human review

Overall PR risk: Low. This change modifies two gh pr diff calls to add --color never, fixing ANSI escape code pollution that breaks diff parsing. The affected surface is small (two argument arrays, one test file) with direct rollback, and the only plausible breakage is on old gh versions without --color support.

🔗 Review setup:

  • This PR changes code the reviewer prompts cite (src, src/tests). Check that the guidance quoting it is still correct.

No findings.


This review is advisory — it never blocks a merge and never auto-approves.

@brentvatne
brentvatne merged commit 2c3b520 into main Oct 23, 2026
3 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.

1 participant