File indexing completed on 2025-01-18 09:10:43
0001
0002
0003
0004
0005
0006
0007
0008 set -e
0009
0010 if [ $
0011 echo "\033[31mERROR\033[0m"\
0012 "wrong number of arguments"
0013 echo "\tusage: check_format <DIR>\n"
0014 exit 1
0015 fi
0016
0017 _binary=${CLANG_FORMAT_BINARY:-clang-format}
0018
0019 $_binary --version
0020
0021 cd $1
0022 find . \( -iname '*.cpp' -or -iname '*.hpp' -or -iname '*.ipp' -or -iname '*.cu' -or -iname '*.cuh' \) \
0023 -and -not -path "./*build*/*" \
0024 -and -not -path "./thirdparty/*" \
0025 | xargs $_binary -i -style=file
0026
0027
0028 if ! [ -z $CI ] || ! [ -z $GITHUB_ACTIONS ]; then
0029 mkdir changed
0030 for f in $(git diff --name-only); do
0031 cp --parents $f changed
0032 done
0033 fi
0034
0035 echo "\033[32mINFO\033[0m"\
0036 "clang-format done"
0037
0038 set +e
0039 git diff --exit-code --stat
0040 result=$?
0041
0042 if [ "$result" -eq "128" ] || [ "$result" -eq "129" ]; then
0043 echo "\033[33mWARNING\033[0m"\
0044 "Could not create summary of affected files"
0045 echo "\tFormat was successfully applied"
0046 echo "\tAre you in a submodule?"
0047 echo "\tYou could try running check_format with sudo.\n"
0048 fi
0049
0050 exit $result