Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:09:24

0001 #!/bin/sh
0002 #
0003 # check that all code complies w/ the clang-format specification
0004 #
0005 # if all is well, returns w/o errors and does not print anything.
0006 # otherwise, return an error and print offending changes
0007 
0008 set -e # abort on error
0009 
0010 if [ $# -ne 1 ]; then
0011     echo "wrong number of arguments"
0012     echo ""
0013     echo "usage: check_format <DIR>"
0014     exit 1
0015 fi
0016 
0017 clang-format --version
0018 
0019 cd $1
0020 find . \( -iname '*.cpp' -or -iname '*.hpp' -or -iname '*.ipp' \) \
0021        -and -not -path "./*build*/*" \
0022        -and -not -path "./Plugins/JsonPlugin/include/Acts/Plugins/Json/lib/*" \
0023   | xargs clang-format -i -style=file
0024 
0025 
0026 if ! [ -z $CI ]; then
0027   mkdir changed
0028   for f in $(git diff --name-only); do
0029     cp --parents $f changed
0030   done
0031 fi
0032     
0033 echo "clang-format done"
0034     
0035 set +e
0036 git diff --exit-code --stat
0037 result=$?
0038 
0039 if [ "$result" -eq "128" ]; then
0040     echo "Format was successfully applied"
0041     echo "Could not create summary of affected files"
0042     echo "Are you in a submodule?"
0043 
0044 fi
0045 
0046 exit $result