mirror of https://github.com/OpenMW/openmw.git
Merge branch 'clang-format-ci-2' into 'master'
Test clang-format project wide in same pipeline See merge request OpenMW/openmw!2423make_linux_ci_do_zoomies
commit
f37d0be806
@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
CLANG_FORMAT="clang-format-14"
|
||||
HAS_DIFFS=0
|
||||
|
||||
check_format() {
|
||||
local path=$1
|
||||
local tempfile=$(mktemp)
|
||||
for item in $(find $path -type f -name "*");
|
||||
do
|
||||
if [[ "$item" =~ .*\.(cpp|hpp|h) ]]; then
|
||||
echo "Checking code formatting on $item"
|
||||
$CLANG_FORMAT $item > $tempfile
|
||||
git diff --color=always --no-index $item $tempfile
|
||||
if [[ $? = 1 ]]; then
|
||||
HAS_DIFFS=1
|
||||
fi
|
||||
fi;
|
||||
done;
|
||||
rm -f $tempfile
|
||||
}
|
||||
|
||||
check_format "./apps"
|
||||
check_format "./components"
|
||||
|
||||
if [[ $HAS_DIFFS -eq 1 ]]; then
|
||||
echo "clang-format differences detected"
|
||||
exit 1
|
||||
fi;
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue