diff options
| author | Avamander <avamander@gmail.com> | 2021-04-18 16:20:16 (GMT) |
|---|---|---|
| committer | JF002 <JF002@users.noreply.github.com> | 2021-07-24 13:55:52 (GMT) |
| commit | a1a6eae43f5995e21ff3d535094a6350e1031804 (patch) | |
| tree | 8225d5e2cfc2f370b362cda85d3b6b33494c0b0e /hooks/pre-commit | |
| parent | bb26c68f2cb971dd2bb6eaa9916ec2372ebcc646 (diff) | |
Added a pre-commit hook that should simplify commiting pre-formatted code
Diffstat (limited to 'hooks/pre-commit')
| -rwxr-xr-x | hooks/pre-commit | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/hooks/pre-commit b/hooks/pre-commit new file mode 100755 index 0000000..2e918a1 --- /dev/null +++ b/hooks/pre-commit @@ -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 |
