summaryrefslogtreecommitdiff
path: root/hooks/pre-commit
diff options
context:
space:
mode:
Diffstat (limited to 'hooks/pre-commit')
-rwxr-xr-xhooks/pre-commit13
1 files changed, 13 insertions, 0 deletions
diff --git a/hooks/pre-commit b/hooks/pre-commit
new file mode 100755
index 00000000..2e918a17
--- /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