Add scripts for running clang-format
This commit is contained in:
parent
79fe8c3435
commit
be0fca914e
3
scripts/clang-format
Executable file
3
scripts/clang-format
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
find . -type f -a '(' -name '*.c' -o -name '*.h' ')' | xargs clang-format -i
|
18
scripts/clang-format-ci
Executable file
18
scripts/clang-format-ci
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/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
|
Loading…
Reference in New Issue
Block a user