19 lines
398 B
Bash
Executable File
19 lines
398 B
Bash
Executable File
#!/bin/bash
|
|
|
|
errors=0
|
|
paths=$(find . -type f -a '(' -name '*.c' -o -name '*.h' ')')
|
|
for path in $paths; do
|
|
in=$(cat $path)
|
|
out=$(clang-format $path)
|
|
|
|
if [ "$in" != "$out" ]; then
|
|
diff -u -L $path -L "$path.formatted" $path - <<<$out
|
|
errors=1
|
|
fi
|
|
done
|
|
|
|
if [ $errors -ne 0 ]; then
|
|
echo "Formatting errors detected, run ./scripts/clang-format to fix!"
|
|
exit 1
|
|
fi
|