Repository navigation
Description
Found while running devkit 1.19.2's pre-commit hook stack on nerdmachines/ee (ee#25).
Problem
The scaffolded .pre-commit-config.yaml enables end-of-file-fixer with no excludes:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # v5.0.0
hooks:
- id: end-of-file-fixerOn a repo with byte-exact golden-file test fixtures, this hook silently rewrites them on the first prek run --all-files. Our Rust parity tests broke immediately: the cyberphone JCS vectors under crates/ee-route/tests/fixtures/jcs/ and the pinned-input traces under crates/ee-route/tests/fixtures/pinned/ all got a trailing \n appended, which made the fixture content no longer match what the canonical-JSON implementation produces — because the test is "byte-exact", expected: b'…}\\n' vs got: b'…}'.
The same happens to mixed-line-ending and trailing-whitespace on a repo with Windows-line-ending golden files or trailing-whitespace-significant fixtures (though we did not hit those).
Impact
The failure is noisy (6 tests failed in our case), but it's downstream of a scaffold-time rewrite that happened quietly. A consumer who runs prek run --all-files the first time and then commits sees a 10-file diff touching test data, whose cause they then have to track down.
We added a narrow exclude per hook:
- id: end-of-file-fixer
exclude: |
(?x)^(
crates/ee-route/tests/fixtures/(jcs|pinned)/.+
| tests/fixtures/jcs/.+
)$Suggested
Three options, in order of ambition:
- Keep the hook on, but add a convention for a scaffold-preserved
.pre-commit-config.project.yamlwhere a consumer's own excludes live (parity with.gitignore.project, [BUG] Managed .gitignore rewrite (#1024) drops consumer-required ignores with no durable committed extension point for repo-root paths #1092). Right now, the config is managed and any exclude is either hand-added to the managed file (lost on upgrade) or belongs in the generator — neither is documented. - Have
init-workspace.shdefaultexclude:to common test-fixture roots (**/tests/fixtures/,**/testdata/) when the hook is first scaffolded. A repo that WANTS end-of-file-fixing on its fixtures can delete it. - Document in SOLO_ADOPTION.md / MIGRATION.md that
end-of-file-fixerwill rewrite golden fixtures, with the exclude-pattern example.
Related: SOLO_ADOPTION doesn't mention the prek run --all-files first-run cost at all; a new adopter is told to adopt and then hit N auto-fixes on the first commit (around 49 auto-fixed files + 30 manual items on our tree). A one-line "expect a sizeable first-pass diff; commit it separately" note would set the expectation.
Not blocking, one-line fix per repo once you know, but the first-run surprise on a fixture-heavy repo is noisy.
Activity