fix(action): strip ANSI colors and fix diff mode on PRs#80
fix(action): strip ANSI colors and fix diff mode on PRs#80bdsqqq wants to merge 6 commits intomillionco:mainfrom
Conversation
two bugs when using the action in pull_request workflows: 1. ANSI escape codes leaked into PR comments — react-doctor uses picocolors which respects NO_COLOR. set NO_COLOR=1 in the env so output piped to the comment is plain text. 2. --diff mode fell back to full scan — actions/checkout checks out a detached HEAD merge commit on pull_request events. react-doctor's getCurrentBranch() returns null for detached HEAD, causing getDiffInfo() to short-circuit. fix: checkout the actual head ref and fetch the base branch when diff input is set. Amp-Thread-ID: https://ampcode.com/threads/T-019c8b27-dfde-7343-a012-143f4d72c106 Co-authored-by: Amp <amp@ampcode.com>
|
@bdsqqq is attempting to deploy a commit to the Million Team on Vercel. A member of the Team first needs to authorize it. |
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
before/after from a real CI runtested on a private monorepo (~800 tsx files) by pointing the action at this fix branch. before (millionco/react-doctor@main):
after (bdsqqq/react-doctor@fix/action-ansi-and-diff):
— igor's agent |
--depth=1 can shallow the local clone and break git merge-base,
which react-doctor uses to find changed files. the bare catch{}
in getChangedFilesSinceBranch silently returns [] on failure,
making diff mode report no changed files.
callers using fetch-depth: 0 already have full history; the
shallow fetch was clobbering it.
Amp-Thread-ID: https://ampcode.com/threads/T-019c8b27-dfde-7343-a012-143f4d72c106
Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019c8b27-dfde-7343-a012-143f4d72c106 Co-authored-by: Amp <amp@ampcode.com>
git fetch origin main stores the result as FETCH_HEAD, not as a local branch ref. git merge-base main HEAD then fails with 'Not a valid object name main'. fix: git fetch origin main:main creates a local ref that merge-base can resolve. Amp-Thread-ID: https://ampcode.com/threads/T-019c8b27-dfde-7343-a012-143f4d72c106 Co-authored-by: Amp <amp@ampcode.com>
update: diff mode now fully workingprevious comment showed ANSI fix working but diff mode was still broken — "No changed source files" even with source changes. root cause: fix: after (verified): only the touched file was scanned (1/1), only its findings shown. the broken full scan had 36+ findings across dozens of files. — igor's agent |
- fetch inputs.diff (not github.base_ref) so diff: staging works even when PR targets main - use git branch -f to avoid non-fast-forward failures on self-hosted runners - graceful fallback (|| true) if fetch/checkout fail — tool reverts to full scan instead of crashing Amp-Thread-ID: https://ampcode.com/threads/T-019c8b27-dfde-7343-a012-143f4d72c106 Co-authored-by: Amp <amp@ampcode.com>
note: fetch-depth requirement for diff modethe diff step needs worth documenting in the README action usage section, something like: # diff mode requires full git history
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: millionco/react-doctor@main
with:
diff: main
github-token: ${{ secrets.GITHUB_TOKEN }}happy to add this to the README in a follow-up PR if you want. — igor's agent |
fixes two bugs in the github action introduced in #63.
ANSI escape codes in PR comments
react-doctor uses picocolors for terminal output. the action pipes this through
teeinto a file, then posts it raw as a PR comment. ANSI codes (^[[32m, etc.) show up as literal text in the markdown code block.fix: set
NO_COLOR=1in the env block. picocolors respects this natively — no stripping needed.--diff mode falls back to full scan
actions/checkoutchecks out a detached HEAD merge commit onpull_requestevents.getCurrentBranch()inget-diff-files.ts:13returnsnullfor detached HEAD (branch === "HEAD" ? null : branch), causinggetDiffInfo()to short-circuit at line 75 and fall back to a full scan.fix: when
diffinput is set on a PR, checkout the actual head ref (github.head_ref) and fetch the base branch. this puts git on a real branch sogetCurrentBranch()succeeds.evidence
spotted in axiomhq/app#7259 — the action posted a comment with raw ANSI and ran a full scan instead of diffing.
— igor's agent