Skip to content

fix(hooks): exclude scaffold-copied CHANGELOG.md from large-file check - #1805

Merged
c-vigo merged 3 commits into
devfrom
bugfix/1801-changelog-large-file-exclude
Oct 1, 2026
Merged

c-vigo merged 3 commits into
devfrom
bugfix/1801-changelog-large-file-exclude

Conversation

@c-vigo

@c-vigo c-vigo commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Description

A fresh devcontainer/both-mode consumer's first commit fails check-added-large-files: the scaffold copies devkit's own, growing CHANGELOG.md to .devcontainer/CHANGELOG.md, and that file has crossed the hook's 500 KB default (514,976 bytes at 1.17.0; 528,063 on dev).

Type of Change

  • fix -- Bug fix

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

  • nix/hooks.nix (the SSoT for the rendered .pre-commit-config.yaml): check-added-large-files now carries exclude: ^\.devcontainer/CHANGELOG\.md$ in its one shared yaml block.
  • This is not a scaffold-only override. devkit's own repo has no .devcontainer/ directory at all, so the identical exclude on the runner's committed .pre-commit-config.yaml matches nothing there and is an inert no-op — one render, both committed YAMLs, no new SSoT concept, no weakening of the drift gate's hook-identity check.
  • Hand-synced both committed YAMLs (.pre-commit-config.yaml and assets/workspace/.pre-commit-config.yaml) to match the new render, as there is no generator script — the drift gate (tests/test_flake_hooks.py) is what keeps nix/hooks.nix and the two committed YAMLs in lockstep.
  • Preserved consumer configs need no fold. An existing consumer's hand-managed .pre-commit-config.yaml is preserved on upgrade (not overwritten), and .devcontainer/CHANGELOG.md is already present in its tree by the time this hook would ever see it there (the hook only rejects added files, per the issue's own "Additional Context"). Only a brand-new scaffold hits the failure, and a brand-new scaffold always renders the fixed config.
  • Kept the diff minimal: did not touch the no-commit-to-branch hook (a parallel branch, The branch-name rule exists only inline in ci.yml, so every consumer's local gate must duplicate it (and drifts) #1760, is rewriting it in the same files).

Changelog Entry

Fixed

  • Fresh scaffold's first commit failed check-added-large-files on .devcontainer/CHANGELOG.md (#1801)
    • The scaffold copies devkit's own, growing CHANGELOG.md into .devcontainer/CHANGELOG.md (528 KB+ on dev), which crossed the hook's 500 KB default. check-added-large-files now excludes that path; devkit's own repo has no .devcontainer/ directory, so the exclude is an inert no-op on devkit's own commits

Testing

  • Tests pass locally (uv run pytest tests/test_flake_hooks.py -q -- 83 passed)
  • Manual testing performed (see below)

Manual Testing Details

TDD: RED commit (9a15369) added TestCheckAddedLargeFilesExcludesScaffoldChangelog, mirroring the existing TestCheckJsonExcludesJsoncBanners pattern -- asserts both committed YAMLs carry the exclude. Verified RED by stashing the implementation and confirming the new test failed (AssertionError on .pre-commit-config.yaml, pre-fix). GREEN commit (4474157) is the fix; test_scaffold_render_is_subset_of_runner (the one-definition identity gate) is untouched and still passes in its original strict form.

Live reproduction and fix proof (nix eval --json .#lib.hooksPortable confirms both runner and scaffold renders carry the identical exclude):

  • Rendered a real --mode devcontainer scaffold via assets/init-workspace.sh, git init && git add -A, ran real prek run check-added-large-files --all-files:
    • Without the exclude (reverted temporarily): fails -- .devcontainer/CHANGELOG.md (515 KB) exceeds 500 KB.
    • With the exclude (as committed): passes.
  • prek run check-added-large-files --all-files in devkit's own repo (both . and assets/workspace prek profiles): passes, confirming the no-op claim (no .devcontainer/ directory exists at devkit's own repo root).
  • just precommit (full prek run --all-files, both profiles): all hooks passed, zero modifications.
  • bats -j$(nproc) tests/bats/init-workspace.bats: 312/312 passed, 0 failures (never ran tests/bats/worktree.bats or the whole bats directory, per this repo's worktree-safety convention).

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs) -- not applicable, no user-facing docs describe this hook's exclude list
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published -- not applicable

Additional Notes

A parallel branch (#1760) is rewriting the no-commit-to-branch hook in the same two files (nix/hooks.nix, both committed .pre-commit-config.yamls); this PR's diff is kept to the one hook/one exclude to ease that merge.

Refs: #1801

c-vigo added 3 commits October 1, 2026 16:26
…check

A fresh devcontainer/both-mode consumer's first commit stages the
scaffold-copied .devcontainer/CHANGELOG.md (528 KB+ on dev), which
check-added-large-files rejects past its 500 KB default. The exclude
lives in the hook's one shared yaml render: devkit's own repo has no
.devcontainer/ directory at all, so the identical exclude on the
runner's committed config is an inert no-op there, keeping a single
render for both committed YAMLs.

Refs: #1801
@c-vigo
c-vigo merged commit 3fc63a2 into dev Oct 1, 2026
17 checks passed
@c-vigo
c-vigo deleted the bugfix/1801-changelog-large-file-exclude branch October 1, 2026 16:29
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.

1 participant