Skip to content

build(pre-commit): stop the whitespace fixers rewriting vendored trees#320

Merged
doublegate merged 1 commit into
mainfrom
build/pre-commit-vendored-exclude
Jul 21, 2026
Merged

build(pre-commit): stop the whitespace fixers rewriting vendored trees#320
doublegate merged 1 commit into
mainfrom
build/pre-commit-vendored-exclude

Conversation

@doublegate

@doublegate doublegate commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Problem

trailing-whitespace, end-of-file-fixer, and mixed-line-ending rewrite files rather than merely checking them, and had no exclude at all. So pre-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:

  • vendored TriCNES C# (crates/rustynes-test-harness/golden/tricnes/)
  • vendored rcheevos C (crates/rustynes-cheevos/vendor/)
  • the immutable ref-docs/ corpus
  • an upstream font licence (assets/RustyNES_Icon/OFL.txt)
  • upstream test-ROM READMEs (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

.markdownlintignore already 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 so pre-commit run --all-files is 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

    • Updated formatting checks to preserve approved whitespace and line-ending conventions in vendored and immutable files.
    • Improved handling of mixed line endings for select upstream files.
  • Style

    • Made minor whitespace-only cleanup in diagnostic tooling without changing behavior.

`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.
Copilot AI review requested due to automatic review settings July 21, 2026 02:15
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 35e26597-697f-45f2-b0ad-237b1b09b577

📥 Commits

Reviewing files that changed from the base of the PR and between e55e9f2 and a762263.

📒 Files selected for processing (2)
  • .pre-commit-config.yaml
  • scripts/diag/celldiff.py

📝 Walkthrough

Walkthrough

Pre-commit whitespace hooks now exclude vendored, upstream, and immutable trees. Two trailing-whitespace-only edits were also made in scripts/diag/celldiff.py, with no logic or control-flow changes.

Changes

Whitespace maintenance

Layer / File(s) Summary
Exclude immutable trees from whitespace hooks
.pre-commit-config.yaml
Shared exclusions were added to the trailing-whitespace, end-of-file-fixer, and mixed-line-ending hooks.
Remove diagnostic script trailing whitespace
scripts/diag/celldiff.py
Trailing whitespace was removed from a comment and a divergence-cap condition without changing behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 9
✅ Passed checks (9 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: pre-commit whitespace hooks now skip vendored trees.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Docs-As-Spec Sync ✅ Passed Diff only touches .pre-commit-config.yaml and a whitespace-only cleanup in scripts/diag/celldiff.py; no crates/rustynes-* behavior changed, so no docs update needed.
Changelog Entry For User-Visible Changes ✅ Passed Only pre-commit config and whitespace-only script edits changed; no user-facing behavior, feature, or bug fix, so no Unreleased changelog entry is required.
No Unwrap/Expect/Panic On Untrusted Input ✅ Passed Diff touches only .pre-commit-config.yaml and whitespace-only edits in scripts/diag/celldiff.py; no new unwrap/expect/panic on untrusted input was added.
Safety Comment On New Unsafe Blocks ✅ Passed HEAD changes only .pre-commit-config.yaml and scripts/diag/celldiff.py; no Rust files or new unsafe blocks were added.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch build/pre-commit-vendored-exclude

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 exclude regex (via YAML anchor) for trailing-whitespace, end-of-file-fixer, and mixed-line-ending to skip vendored and immutable reference paths.
  • Fix two real trailing-whitespace instances in scripts/diag/celldiff.py so a full pre-commit run --all-files stays 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.

@doublegate

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@doublegate
doublegate merged commit a69200e into main Jul 21, 2026
23 checks passed
@doublegate
doublegate deleted the build/pre-commit-vendored-exclude branch July 21, 2026 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants