fix(git-hooks): scope pre-push lint to branch-changed files only - #2247
Conversation
👷 Deploy request for cedarjs pending review.Visit the deploys page to approve it
|
Greptile SummaryThe pre-push hook now lints only files changed against the local
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains in the changed pre-push lint flow, and the previously reported issues are addressed by explicit Git-ref validation and package-aware lint routing. Important Files Changed
Reviews (7): Last reviewed commit: "refactor(git-hooks): fail fast with a cl..." | Re-trigger Greptile |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run-many -t build:pack --exclude create-ceda... |
✅ Succeeded | 5s | View ↗ |
nx run-many -t build |
✅ Succeeded | <1s | View ↗ |
nx run-many -t build --output-style=stream |
✅ Succeeded | 2m 48s | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-07-27 16:15:15 UTC
8f03a58 to
23c70ad
Compare
|
Fixed both issues from Greptile:
|
23c70ad to
ff0580f
Compare
|
Fixed three additional P1 issues:
|
Running `yarn lint` on all packages on every push was slow and memory-intensive (OOM in containers). The pre-commit hook already lints staged files; the pre-push hook only needs to catch anything not covered there. Switch to linting only files changed in the branch vs main using `git diff main...HEAD`, using the same `runEslint()` / `getFilesToLint()` helpers already used by the pre-commit hook. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ff0580f to
0f505af
Compare
|
Fixed: |
… CI git state The test called the real (unmocked) getBranchChangedFiles(), which shells out to `git diff main...HEAD`. On CI's shallow PR checkout there's no local `main` ref and no `upstream` remote, so the fetch-fallback logic threw, failing the test on both ubuntu-latest and windows-latest. Mock node:child_process's spawnSync so the test is deterministic and update the assertions to look for the `yarn eslint` call instead of the old `yarn lint` command, which no longer exists after scoping lint to branch-changed files.
The comment claimed the branch-wide diff "catches anything not yet committed", but getBranchChangedFiles() only diffs committed changes (main...HEAD) — it never touches the working tree. Clarify the actual reason for linting the whole branch diff instead of just the current commit: pre-commit only lints per-commit staged files and can be skipped with --no-verify, so some committed changes may slip through.
…missing Replace the multi-remote fetch-and-retry fallback in getBranchChangedFiles() with a simple upfront check (`git rev-parse --verify main`). Silently fetching main from a remote inside a git hook was fragile (network-dependent, remote-name-dependent) and was the root cause of a prior CI test failure. Now we just tell the developer exactly what to run instead.
|
These P1 comments are all on earlier commits that I've now superseded with a simpler approach. The latest commit (c04c4f3) removes the multi-remote fetch-and-retry logic entirely and replaces it with a straightforward upfront check ( This eliminates all three issues Greptile flagged:
CI has already validated the fix with all checks passing (including both build-lint-test jobs on ubuntu and windows that were previously failing). |
|
The changes in this PR are now available on npm. Try them out by running Or try it in a new app with |

Problem
The pre-push hook runs
yarn lint, which ESLints all ofpackages/. On a monorepo with 70+ packages this is slow (~minutes) and extremely memory-hungry — in containers with ~4GB RAM it OOM-kills consistently.Fix
Instead of linting all packages, lint only the files changed in the branch vs
main, usinggit diff main...HEAD. This reuses the samegetBranchChangedFiles()helper,getFilesToLint()filter, andrunEslint()function already used by the pre-commit hook for staged files.The result: lint time is proportional to the size of your change, not the size of the repo. A branch touching one file lints one file.
The build still runs in full (
yarn build) so cross-package breakage from dependency changes is still caught. Lint still runs after build (not in parallel) to preserve the existing guarantee that template ESLint configs canrequire()dist output.