build(pre-commit): stop the whitespace fixers rewriting vendored trees#320
Conversation
`trailing-whitespace`, `end-of-file-fixer`, and `mixed-line-ending` REWRITE files rather than merely checking them, and had no exclusion at all. A `pre-commit run --all-files` therefore silently reformatted 41 files across trees this repo deliberately keeps byte-identical to upstream: the vendored TriCNES C# under crates/rustynes-test-harness/golden/tricnes/, the vendored rcheevos C under crates/rustynes-cheevos/vendor/, the immutable ref-docs/ corpus, an upstream font licence (assets/RustyNES_Icon/OFL.txt), and upstream test-ROM READMEs. That is a real defect, not a cosmetic one. Those trees exist precisely so they can be diffed against upstream and so provenance/licence text stays verbatim; rewriting them destroys that property, and it does so during a command the contributing docs actively recommend (line 4 of this file). It also drags unrelated churn into whatever change happened to run the hooks broadly. .markdownlintignore already exempted most of these paths for markdownlint. This is the missing equivalent for the fixers, shared across all three via a YAML anchor so the three lists cannot drift apart. Scope is deliberately NARROWER than .markdownlintignore: only content we did not author (vendored / upstream / immutable reference). Frozen-but-ours trees — docs/archive/, to-dos/archive/, to-dos/plans/, docs/monetization/ — stay in scope, because they are our own prose and whitespace hygiene on them is harmless. Excluding them would over-fit the rule to "things markdownlint skips" rather than to the actual invariant being protected. Verified by re-running the exact command that caused the damage: it now reports 41 fewer modified files, touching only scripts/diag/celldiff.py — our own script, with two genuine trailing-whitespace slips, fixed here so `pre-commit run --all-files` is clean from a clean tree.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughPre-commit whitespace hooks now exclude vendored, upstream, and immutable trees. Two trailing-whitespace-only edits were also made in ChangesWhitespace maintenance
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 9✅ Passed checks (9 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Updates the repo’s pre-commit configuration to prevent whitespace-fixing hooks from rewriting vendored/upstream/immutable trees, preserving “byte-identical to upstream” invariants and avoiding unrelated churn when running pre-commit run --all-files.
Changes:
- Add a shared
excluderegex (via YAML anchor) fortrailing-whitespace,end-of-file-fixer, andmixed-line-endingto skip vendored and immutable reference paths. - Fix two real trailing-whitespace instances in
scripts/diag/celldiff.pyso a fullpre-commit run --all-filesstays clean.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
scripts/diag/celldiff.py |
Removes trailing whitespace in two lines to keep pre-commit clean. |
.pre-commit-config.yaml |
Excludes vendored/upstream/immutable paths from rewriting whitespace fixer hooks using a shared YAML anchor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@coderabbitai review |
✅ Action performedReview finished.
|
Problem
trailing-whitespace,end-of-file-fixer, andmixed-line-endingrewrite files rather than merely checking them, and had noexcludeat all. Sopre-commit run --all-files— the command this very config recommends on line 4 — silently reformatted 41 files across trees the repo deliberately keeps byte-identical to upstream:crates/rustynes-test-harness/golden/tricnes/)crates/rustynes-cheevos/vendor/)ref-docs/corpusassets/RustyNES_Icon/OFL.txt)tests/roms/)Found the hard way while preparing #319.
This is a real defect rather than a cosmetic one. Those trees exist so they can be diffed against upstream and so provenance/licence text stays verbatim — rewriting them destroys exactly that property. It also drags unrelated churn into whatever change happened to run the hooks broadly.
Fix
.markdownlintignorealready exempted most of these paths for markdownlint. This adds the missing equivalent for the three rewriting hooks, shared via a YAML anchor so the lists cannot drift apart.Scope is deliberately narrower than
.markdownlintignore: only content we did not author (vendored / upstream / immutable reference). Frozen-but-ours trees —docs/archive/,to-dos/archive/,to-dos/plans/,docs/monetization/— stay in scope, because they are our own prose and whitespace hygiene on them is harmless. Excluding them would over-fit the rule to "whatever markdownlint skips" rather than to the invariant actually being protected.The read-only hooks (
check-yaml,check-toml,check-merge-conflict) are intentionally left alone — they modify nothing, so running them over vendored files is harmless and mildly useful.Verification
Re-ran the exact command that caused the damage. It now reports 41 fewer modified files, touching only
scripts/diag/celldiff.py— our own script, with two genuine trailing-whitespace slips, fixed here sopre-commit run --all-filesis clean from a clean tree.Scope
Tooling configuration plus two whitespace characters in a diagnostic script. No workflow, source, build output, or emulation behavior changes.
Summary by CodeRabbit
Chores
Style