Repository navigation
chore: track the @date/@copyright hook and stop it stamping unchanged files - #153
Merged
Merged
Conversation
… files The hand-written .git/hooks/pre-commit occupied the hook slot without ever chaining to pre-commit, so no-commit-to-branch, clang-format and the whitespace fixers declared in .pre-commit-config.yaml never ran locally. It also stamped @Date on every staged .cpp/.h unconditionally, which turned any `git add -A` into a spray of one-line date bumps that pad diffs and conflict between long-lived branches. Move the logic into a tracked script registered as a local pre-commit hook. It now stamps only when the staged diff contains a change other than the metadata lines themselves; a metadata-only change is restored from HEAD. Skipped on pre-commit.ci, where the date would be the build date. Contributors need the one-time `pip install pre-commit && pre-commit install` documented in CONTRIBUTING.md. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Problem
A hand-written
.git/hooks/pre-commitoccupied the hook slot on my machine and never chained to the pre-commit framework. Two consequences:.pre-commit-config.yaml—no-commit-to-branch,clang-format,trailing-whitespace,end-of-file-fixer,mixed-line-ending— was silently inert locally.@date/@copyrighton every staged.cpp/.h, whether or not the file had actually been edited. Anygit add -Aturned into a spray of one-line date bumps. On feat: left-aligned ADC and circular channel list (#121) #127 that was 7 files of pure churn, all of them conflict bait againstfeature/remote-loads.Change
scripts/hooks/update-metadata.sh— the same logic, tracked and fixed. It stamps only when the staged diff contains a change other than the metadata lines themselves; a metadata-only change is restored from HEAD instead. Newly added files always stamp. Likeclang-format, it rewrites the file and fails rather than callinggit additself (staging from inside a hook interferes with pre-commit's stash handling)..pre-commit-config.yaml— registers it as alocalhook and addsci: skip: [update-metadata], so pre-commit.ci never stamps headers with the build date.CONTRIBUTING.md— documents the hook and the CI skip.Testing
Exercised all three paths against a tracked header:
@datebump onlyNote for anyone with a local checkout
The hand-written hook has to go for the framework shim to take the slot. One-time setup, already documented in
CONTRIBUTING.md:🤖 Generated with Claude Code