Add CLAUDE.md and a clang-format pre-commit hook#264
Merged
Conversation
Runs the same clang-format --dry-run --Werror check as CI (.github/workflows/format.yml) on the staged content of C/C++ files under src/, codes/, doc/, and tests/, rejecting the commit with a fix-it command on drift so formatting fixups never need their own commit. Checks the index (git show :file), not the worktree, so partially staged files are judged on what would actually land; warns when the local clang-format major differs from CI's pinned 20. Opt-in per clone via 'git config core.hooksPath scripts/git-hooks' (documented in the README); bypass a single commit with --no-verify.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
I keep forgetting to add a CLAUDE.md file, which would probably be useful.
Also adding a pre-commit hook that will run clang-format on any staged C/C++ files. This way those errors are caught before getting to CI. I also personally hate having a bunch of commits that are just "fixing formatting issues" so this will remind you (me) to do it. You do have to opt into it.
Added to the README:
When you have this enabled and try to commit a file that won't pass clang-format, you will get the following output:
If you use claude, it should handle running clang-format for you due to instructions in CLAUDE.md