Run check_syntax as pre-commit hook#3310
Merged
Merged
Conversation
Prompt: "Modify script "check_syntax" to optionally take as input the currently staged git diff. When this is present, execute the same test of tests as are otherwise executed on all C++ source files upon the set of line additions present in the diff. Then configure a new git pre-commit hook to execute "check_syntax" upon the staged diff." Generated-by: Claude Sonnet 4.6 <noreply@anthropic.com>.
This comment was marked as outdated.
This comment was marked as outdated.
Member
Author
|
There is a mild risk in this approach:
In this "diff" mode however, the input will be a concatenation of all newly added lines.
I think these are decreasingly likely to occur, but it's imperfect nonetheless. Possible strategies:
|
Prompts: "In script "check_syntax", when operating in diff mode, ensure that what is passed to the grep checks is not only newly added lines, but also the surrounding context lines." "In script "check_syntax", when operating in diff mode, where there is a discontinuity in the lines of the originating file shown, introduce a delimiter into the file that will prevent any of the regular expression tests from matching across that delimiter." Generated-by: Claude Opus 4.6 <noreply@anthropic.com>
This comment was marked as outdated.
This comment was marked as outdated.
|
clang-tidy review says "All clean, LGTM! 👍" |
This was referenced Apr 18, 2026
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.
Felt the itch to give this a try, and Claude seems to have done a functional job of it.
I tried adding a second commit that contained code that would violate
check_syntax. The pre-commit hook rejected it. It was clear from the response time thatcheck_syntaxwas only executing against the git diff and not the entire codebase. So might be a useful one to drag in just to cut back on pluralistic commits.Closes #3301.