Build: add clang-15.0.6 docker image
[marnav.git] / bin / check-format
blob6f2a2b7c18610f3c8d4a4324efb8679505435c89
1 #!/bin/bash -eu
3 export SCRIPT_BASE=$(dirname `readlink -f $0`)
4 export BASE=${SCRIPT_BASE}/..
6 # search for a suitable clang-format version
7 CLANG_FORMAT_BIN=`which clang-format-10`
8 if [ ! -x ${CLANG_FORMAT_BIN} ] ; then
9 echo "error: clang-format not found. abort."
10 exit 1
13 # performing checks
14 cd ${BASE}
15 FILES=()
16 for fn in $(find src include test examples -type f -name "*.[ch]pp") ; do
17 if [ "$(${CLANG_FORMAT_BIN} "$fn" | diff "$fn" -)" ] ; then
18 FILES+=($fn)
20 done
22 # abort commit and show violating files
23 if [ ${#FILES[@]} -gt 0 ] ; then
24 for fn in ${FILES[@]} ; do
25 echo " $fn"
26 done
27 exit 1
30 exit 0