Skip to content

Baseline degrades to plain diff when the change set deletes a file; action blames a shallow checkout #1768

Description

@niklasp

Summary

--scope changed degrades to a plain diff (mode: "diff", baselineDegraded: true) whenever the change set contains a deleted source file. The history is complete and the merge-base resolves, yet the GitHub Action comment says the checkout is shallow and asks for fetch-depth: 0, which is already set.

Environment

  • react-doctor 0.9.13 (also reproduced with 0.9.11)
  • GitHub Action millionco/react-doctor@v2, directory: <subdir>, scope: changed, actions/checkout@v5 with fetch-depth: 0
  • Locally: macOS, Node 22.22.0, git 2.52.0, full clone
  • Project: TanStack Start app inside a pnpm monorepo (the scanned directory is a subdirectory of the repo)

Repro

PR with four commits; the first one deletes a .tsx component file and edits a handful of other .tsx and locale .json files. <base> is the PR's base commit (merge-base with HEAD is <base> itself, verified with git merge-base).

cd <subdir>
npx react-doctor@0.9.13 . --json --json-compact --scope changed --base <base> --no-cache
# -> "mode":"diff","baselineDegraded":true

Isolating the trigger:

Scenario mode baselineDegraded
base = PR base, PR content as committed diff true
same with react-doctor 0.9.11 diff true
base = first PR commit (deletion no longer in the diff) baseline
base = PR base, deleted file staged back (git checkout <base> -- <file>) baseline
base = PR base, every other change of the first commit reverted, deletion kept diff true

Reverting the locale JSON edits or the other .tsx edits changes nothing; only the deletion flips the result. Note that restoring the file as an untracked copy is not enough, git diff <base> still reports D for it, which is what the baseline planner reads.

What the action reports

⚠️ Warning: .github/workflows/<workflow>.yml is configured incorrectly.
React Doctor compares against `<base branch>` to report only the issues this pull request introduces.
This run couldn't complete that comparison (usually a shallow CI checkout with no merge base) …
Add `fetch-depth: 0` to the `actions/checkout` step …

In the same run the action's own base step fetched the base SHA and derived the changed files with git diff <base>...HEAD without falling back to the API, so the base is reachable. Earlier PRs on the same repo and workflow (no deletions) got mode: "baseline".

Expected

  • A deleted file should not prevent the baseline delta. The file's base diagnostics can simply count as fixed; there is nothing to compare at head.
  • If the baseline still has to degrade, the PR comment should say why (e.g. which step returned no delta) instead of attributing it to a shallow checkout. The current text sends people to change a checkout that is already correct (baselineDegraded with rootDir when Action directory is repo root (misattributes to shallow checkout) #1456 fixed the same misattribution for another trigger).

Notes from reading the source

runBaselineComparison returns null in several places without a reason surfacing anywhere (materializeBaselineFilesnull, !snapshot.isComplete, unanalyzed expected head files, base lint failure). parseBaselineDiffPlan puts D entries into baseFiles, so the deleted file is materialised and linted at base; one of the later checks then drops the whole delta. I could not tell which one from the outside, --verbose prints nothing about it. A debug line naming the failing check would make this diagnosable.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions