docs: add guide on setting up a clang-format pre-commit hook - #63
Open
shenxianpeng wants to merge 2 commits into
Open
shenxianpeng wants to merge 2 commits into
shenxianpeng wants to merge 2 commits into
Conversation
✅ Deploy Preview for cpp-linter-github-io ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Why
cpp-linter-hooks already gets more Google traffic than the action (52 of its 288 repository views in the last 14 days came from Google, against 21 for cpp-linter-action), so people are searching for "clang-format pre-commit hook". The site has no page for that query. This is the second how-to written around a search term, after #62; the two PRs are independent.
What's in this PR
One new post in the Guides category: Set up a clang-format pre-commit hook for C and C++ (
docs/blog/posts/2026-09-20-clang-format-pre-commit-hook.md), published at/blog/2026/09/20/clang-format-pre-commit-hook/(explicitslug, plus a metadescription)..clang-format.revis the hook version,--versionis the clang-format version (21resolves to the newest 21.x wheel, a full version pins it exactly).exclude, aDisableFormat.clang-formatin the vendored directory, andtypes_orfor CUDA and Protobuf..git-blame-ignore-revs, or format as you go;git clang-formatmentioned for changed-lines-only.pre-commit run --all-files --show-diff-on-failure, or review suggestions from cpp-linter-action withformat-review.Checks
rev: v1.6.0and--version=21(resolved to clang-format 21.1.8): the blocked commit and the retry,exclude, the per-directoryDisableFormat,.cuand.protoformatting viatypes_or,SKIP=clang-format, the CI output (pasted verbatim) andblame.ignoreRevsFile.clang_tidy.pyat v1.6.0.mkdocs build --strictpasses locally, and the repository's pre-commit hooks pass on the new file.Notes
--dry-run. With the released v1.6.0 the hook reports "Passed" for an unformatted file when--dry-runis set, with or without--Werror; the fix (fix: make --dry-run correctly report formatting issues cpp-linter-hooks#257) is onmainbut not in a release yet. Once it is released, a check-only variant can be added to step 6.mainyet and the strict build would fail. The two posts can be cross-linked in a small follow-up once both are merged.