-
Notifications
You must be signed in to change notification settings - Fork 24
add instruction to add pre-commit clang-format hook #103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -481,9 +481,10 @@ In some cases, you may need to perform a full clean that deletes all build artif | |
| ``` | ||
|
|
||
| ### Clang format | ||
| CPP SDK is using clang C++ format | ||
| CPP SDK is using clang C++ format, and set up the pre-commit hook (run once): | ||
| ```bash | ||
| brew install clang-format | ||
| printf '#!/bin/sh\necho "Running clang-format..."\nFILES=$(git diff --cached --name-only -- "*.cpp" "*.cc" "*.h" "*.hpp")\n[ -z "$FILES" ] && exit 0\nfor f in $FILES; do clang-format -i "$f"; git add "$f"; done\necho "clang-format completed."\n' > .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As an alternative (or an addition), could we add this to the build scripts? I.e. check if the hook exists, then create it if not? That way we could have better enforcement
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like there are some more automatic/elegant solutions, example: https://github.com/polymathrobotics/livekit_ros2_bridge/blob/main/.pre-commit-config.yaml |
||
| ``` | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼