fix(ci): improve changed file detection in linter script - #8968
fix(ci): improve changed file detection in linter script#8968shivanee-p wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the linter script to fetch the base branch when running in a GitHub Actions environment and refactors the list of Git references used to determine changed files. The reviewer suggested using an explicit refspec in the git fetch command to ensure the remote-tracking branch is correctly created and updated in shallow-clone CI environments.
a449965 to
2a57889
Compare
|
/gemini |
|
Hello! It looks like you've invoked me to help with this pull request. Since you didn't specify a command, I've provided a summary of your changes below. Pull Request Summary:
|
c69d6c6 to
d0f8a21
Compare
…on under shared sub-root configs
88c3e97 to
ee44be0
Compare
…oot .eslintrc.json
76b0942 to
480b5d0
Compare
Fixes an issue where
./bin/linter.mjsskipped TypeScript checks in CI pull request workflows because it's incorrectly detecting no TS file changes.It looks like the CI was comparing "head" to "head". It was running
git diff FETCH_HEAD -- *.ts, but we need to fetch from origin before doing that. Previously, the linter was going in order of therefsToTryarray to check which reference existed in order to diff against it:main,upstream/main, andorigin/mainfailed'FETCH_HEAD', existed and pointed to the checked-out PR commit (HEAD).git diff --name-only FETCH_HEAD -- *.tscomparedHEADagainst itself, which succeeded with an exit code of0and returned an empty file list ("")Fix
process.env.GITHUB_BASE_REFis defined), executegit fetch origin ${base} --depth=1to ensureorigin/${base}exists locally.origin/${base}...HEAD,${base}...HEAD, etc.) to diff from the common ancestor between the target branch and the feature branch.'FETCH_HEAD'from candidate refs to prevent Git from comparingHEADto itself in shallow single-ref checkouts.Verification
Simulated CI environment on branch
test-pr-8966(GITHUB_BASE_REF=main):origin/main...HEADmatched successfully after fetching.