From dd6fd808a65217853c899f35688d83d83ad0d716 Mon Sep 17 00:00:00 2001 From: Igor Bedesqui Date: Mon, 23 Feb 2026 19:31:21 +0000 Subject: [PATCH 1/6] fix(action): strip ANSI colors and fix diff mode on PRs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- action.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/action.yml b/action.yml index 1fe8015..1099f16 100644 --- a/action.yml +++ b/action.yml @@ -39,8 +39,17 @@ runs: with: node-version: ${{ inputs.node-version }} + - if: ${{ inputs.diff != '' && github.event_name == 'pull_request' }} + shell: bash + run: | + git fetch origin ${{ github.base_ref }} --depth=1 + git checkout ${{ github.head_ref }} + env: + GITHUB_TOKEN: ${{ inputs.github-token }} + - shell: bash env: + NO_COLOR: "1" INPUT_DIRECTORY: ${{ inputs.directory }} INPUT_VERBOSE: ${{ inputs.verbose }} INPUT_PROJECT: ${{ inputs.project }} From ec3787c341b7f52324b9377b432858efcf11c747 Mon Sep 17 00:00:00 2001 From: Igor Bedesqui Date: Tue, 24 Feb 2026 11:04:04 +0000 Subject: [PATCH 2/6] Update action.yml Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com> --- action.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 1099f16..76d5121 100644 --- a/action.yml +++ b/action.yml @@ -42,10 +42,12 @@ runs: - if: ${{ inputs.diff != '' && github.event_name == 'pull_request' }} shell: bash run: | - git fetch origin ${{ github.base_ref }} --depth=1 - git checkout ${{ github.head_ref }} + git fetch origin "$BASE_REF" --depth=1 + git checkout "$HEAD_REF" env: GITHUB_TOKEN: ${{ inputs.github-token }} + BASE_REF: ${{ github.base_ref }} + HEAD_REF: ${{ github.head_ref }} - shell: bash env: From 9044ee04bac5df338676e415c61ae2a19561270d Mon Sep 17 00:00:00 2001 From: Igor Bedesqui Date: Tue, 24 Feb 2026 12:50:22 +0000 Subject: [PATCH 3/6] fix(action): drop --depth=1 from base branch fetch --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 --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 76d5121..8d676e6 100644 --- a/action.yml +++ b/action.yml @@ -42,7 +42,7 @@ runs: - if: ${{ inputs.diff != '' && github.event_name == 'pull_request' }} shell: bash run: | - git fetch origin "$BASE_REF" --depth=1 + git fetch origin "$BASE_REF" git checkout "$HEAD_REF" env: GITHUB_TOKEN: ${{ inputs.github-token }} From 736a8533526762c307733164fc44b82601528b8c Mon Sep 17 00:00:00 2001 From: Igor Bedesqui Date: Tue, 24 Feb 2026 12:57:25 +0000 Subject: [PATCH 4/6] debug: trace git state in CI to find diff failure Amp-Thread-ID: https://ampcode.com/threads/T-019c8b27-dfde-7343-a012-143f4d72c106 Co-authored-by: Amp --- action.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/action.yml b/action.yml index 8d676e6..8e3248e 100644 --- a/action.yml +++ b/action.yml @@ -42,8 +42,21 @@ runs: - if: ${{ inputs.diff != '' && github.event_name == 'pull_request' }} shell: bash run: | + echo "::group::Debug git state before fix" + echo "HEAD before: $(git rev-parse --abbrev-ref HEAD)" + echo "Branches: $(git branch -a | head -20)" + echo "::endgroup::" git fetch origin "$BASE_REF" git checkout "$HEAD_REF" + echo "::group::Debug git state after fix" + echo "HEAD after: $(git rev-parse --abbrev-ref HEAD)" + MERGE_BASE=$(git merge-base "$BASE_REF" HEAD 2>&1) && echo "merge-base: $MERGE_BASE" || echo "merge-base FAILED: $MERGE_BASE" + echo "Changed files (from repo root):" + git diff --name-only --diff-filter=ACMR "$MERGE_BASE" HEAD 2>&1 | head -20 + echo "Changed files (--relative from ${{ inputs.directory }}):" + cd "${{ inputs.directory }}" && git diff --name-only --diff-filter=ACMR --relative "$MERGE_BASE" HEAD 2>&1 | head -20 + cd - + echo "::endgroup::" env: GITHUB_TOKEN: ${{ inputs.github-token }} BASE_REF: ${{ github.base_ref }} From c063530896fc24764422a4dbba7da4b4c502bd19 Mon Sep 17 00:00:00 2001 From: Igor Bedesqui Date: Tue, 24 Feb 2026 13:06:31 +0000 Subject: [PATCH 5/6] fix(action): fetch base branch as local ref, not FETCH_HEAD 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 --- action.yml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/action.yml b/action.yml index 8e3248e..3c676c2 100644 --- a/action.yml +++ b/action.yml @@ -42,21 +42,8 @@ runs: - if: ${{ inputs.diff != '' && github.event_name == 'pull_request' }} shell: bash run: | - echo "::group::Debug git state before fix" - echo "HEAD before: $(git rev-parse --abbrev-ref HEAD)" - echo "Branches: $(git branch -a | head -20)" - echo "::endgroup::" - git fetch origin "$BASE_REF" + git fetch origin "$BASE_REF":"$BASE_REF" git checkout "$HEAD_REF" - echo "::group::Debug git state after fix" - echo "HEAD after: $(git rev-parse --abbrev-ref HEAD)" - MERGE_BASE=$(git merge-base "$BASE_REF" HEAD 2>&1) && echo "merge-base: $MERGE_BASE" || echo "merge-base FAILED: $MERGE_BASE" - echo "Changed files (from repo root):" - git diff --name-only --diff-filter=ACMR "$MERGE_BASE" HEAD 2>&1 | head -20 - echo "Changed files (--relative from ${{ inputs.directory }}):" - cd "${{ inputs.directory }}" && git diff --name-only --diff-filter=ACMR --relative "$MERGE_BASE" HEAD 2>&1 | head -20 - cd - - echo "::endgroup::" env: GITHUB_TOKEN: ${{ inputs.github-token }} BASE_REF: ${{ github.base_ref }} From 5cfcb0b2e46a85efd26e5ec8457d9ffd57f126a4 Mon Sep 17 00:00:00 2001 From: Igor Bedesqui Date: Tue, 24 Feb 2026 14:10:36 +0000 Subject: [PATCH 6/6] fix(action): fetch diff input ref instead of PR base, handle edge cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- action.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 3c676c2..8cc891b 100644 --- a/action.yml +++ b/action.yml @@ -42,11 +42,13 @@ runs: - if: ${{ inputs.diff != '' && github.event_name == 'pull_request' }} shell: bash run: | - git fetch origin "$BASE_REF":"$BASE_REF" - git checkout "$HEAD_REF" + # create local ref for the diff base so git merge-base can resolve it + git fetch origin "$DIFF_BASE" && git branch -f "$DIFF_BASE" FETCH_HEAD 2>/dev/null || true + # checkout the PR head branch so getCurrentBranch() doesn't return null + git checkout "$HEAD_REF" 2>/dev/null || true env: GITHUB_TOKEN: ${{ inputs.github-token }} - BASE_REF: ${{ github.base_ref }} + DIFF_BASE: ${{ inputs.diff }} HEAD_REF: ${{ github.head_ref }} - shell: bash