Added a pre-commit hook that should simplify commiting pre-formatted code
This commit is contained in:
parent
bb26c68f2c
commit
a1a6eae43f
5
hooks/README.md
Normal file
5
hooks/README.md
Normal file
|
@ -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`
|
13
hooks/pre-commit
Executable file
13
hooks/pre-commit
Executable file
|
@ -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
|
Loading…
Reference in New Issue
Block a user