summaryrefslogtreecommitdiff
path: root/hooks/pre-commit
blob: 2e918a17dcf88566ba3980eda6c5902e67fd75ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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