forked from InfiniTimeOrg/InfiniTime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a pre-commit hook that should simplify commiting pre-formatted …
…code
- Loading branch information
Showing
2 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Git hooks | ||
|
||
This directory contains Git hooks that simplify contributing to this repository. | ||
|
||
You can install them by copying the files into `.git/hooks` in the repository folder or by running `git config --local core.hooksPath hooks` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
for FILE in $(git diff --cached --name-only) | ||
do | ||
if [[ "$FILE" =~ src/[A-Za-z0-9\ \-]+*\.(c|h|cpp|cc)$ ]]; then | ||
echo Autoformatting $FILE with clang-format | ||
clang-format-11 -style=file -i -- $FILE | ||
git add -- $FILE | ||
elif [[ "$FILE" =~ src/(components|displayapp|drivers|heartratetask|logging|systemtask)/.*\.(c|h|cpp|cc)$ ]]; then | ||
echo Autoformatting $FILE with clang-format | ||
clang-format-11 -style=file -i -- $FILE | ||
git add -- $FILE | ||
fi | ||
done |