chore: pre-commit hook to reject oversized files, ignore Testing/ - #121
Merged
Merged
Conversation
Add a pre-commit hook (dev/git-hooks/pre-commit) that rejects a commit
staging any file over 256 KiB, sized from the index so it works with
partial stages and with `git commit <paths>`. It is not installed
automatically; dev/install-git-hooks symlinks it (and anything else
under dev/git-hooks/) into the hooks directory git actually runs -
.git/hooks in a plain clone, or the common git dir for a linked
worktree, so one run covers every worktree of a clone. Bypass with
`git commit --no-verify` when a large file is genuinely project
content.
Also ignore Testing/, which `ctest` writes at the repo root
(Testing/Temporary/{LastTest.log,CTestCostData.txt}) whenever it's
run from there rather than from build/.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The local pre-commit hook is opt-in - nothing forces a contributor to run dev/install-git-hooks, and it's `--no-verify`-bypassable regardless. Add a "File size" CI job that re-checks the same 256 KiB limit server-side, over every blob any commit in the pull request introduces (not just the files that differ in the final base...head diff), so an oversized file can't reach develop even if the local hook never ran. A commit that adds a large file and a later commit in the same PR that shrinks or removes it again is still a permanent addition to history once merged - checking only the net diff would miss it, and checking every commit's blobs catches it. Extract the size check itself into dev/check-blob-size, shared by the hook and the CI job so the limit and the message live in one place. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
An automated preview of the documentation is available at https://121.openmethod.prtest3.cppalliance.org/libs/openmethod/doc/html/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-09-19 00:57:21 UTC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(Written by Claude Code, on behalf of @jll63.)
Adds a size limit on committed files: a local pre-commit hook (opt-in), and
a CI job that enforces the same limit server-side so it isn't bypassable by
skipping local setup or by
--no-verify. Also ignores CTest's strayTesting/output at the repo root.dev/check-blob-size <oid> <path>- the check itself: rejects a blob over256 KiB. Shared by the hook and the CI job, so the limit and the message
live in one place.
dev/git-hooks/pre-commit- runs the check over every file staged for acommit, sized from the index (
git cat-file -s :path) so it's correct forpartial stages (
git add -p) and forgit commit <paths>(git hands thehook a temporary index). Bypass with
git commit --no-verifywhen a largefile genuinely belongs.
dev/install-git-hooks- symlinks everything underdev/git-hooks/intothe hooks directory git actually runs. Resolved via
git rev-parse --git-path hooks, so one run also covers every linkedworktree of a clone, not just the one it's run from.
in a pull request introduces, not just the files that differ in the final
base...head diff. A commit that adds an oversized file and a later commit
in the same PR that shrinks or removes it again still leaves that blob in
history forever once merged; checking only the net diff would miss it.
This is what actually makes the limit non-optional - the local hook is a
convenience, this is the enforcement.
.gitignore- ignoreTesting/, whichctestwrites at the repo root(
Testing/Temporary/{LastTest.log,CTestCostData.txt}) whenever it's runfrom there rather than from
build/.🤖 Generated with Claude Code