bootstrap/.githooks/pre-commit

14 lines
240 B
Plaintext
Raw Normal View History

2023-11-23 15:21:50 +00:00
#!/usr/bin/env bash
set -e
filesToFormat=$(
git --no-pager diff --name-status --no-color --cached | \
2023-11-25 02:35:22 +00:00
awk '$1 != "D" && $2 ~ /\.c$|\.h$/ {print $NF}'
2023-11-23 15:21:50 +00:00
)
for path in $filesToFormat
do
clang-format -i "$path"
git add "$path"
done;