@@ -24,11 +24,12 @@ COMMAND=$*
2424SCRIPTPATH=" $( cd " $( dirname " $0 " ) " ; pwd -P ) "
2525MAINSOURCE=$SCRIPTPATH /..
2626ALL_FILES=$( cd $MAINSOURCE && git ls-tree --full-tree --name-only -r HEAD | grep -e " .*\.\(c\|h\|cc\|cpp\|hh\)\$ " )
27+ CLANG_FORMAT_MAJOR_VERSION=17
2728
28- if clang-format-17 --version 2> /dev/null | grep -qF ' version 17. ' ; then
29- cd $MAINSOURCE ; clang-format-17 --style=file --verbose -i " $@ " $ALL_FILES
29+ if " clang-format-$CLANG_FORMAT_MAJOR_VERSION " --version 2> /dev/null | grep -qF " version $CLANG_FORMAT_MAJOR_VERSION . " ; then
30+ cd $MAINSOURCE ; " clang-format-$CLANG_FORMAT_MAJOR_VERSION " --style=file --verbose -i " $@ " $ALL_FILES
3031 exit 0
31- elif clang-format --version 2> /dev/null | grep -qF ' version 17. ' ; then
32+ elif clang-format --version 2> /dev/null | grep -qF " version $CLANG_FORMAT_MAJOR_VERSION . " ; then
3233 cd $MAINSOURCE ; clang-format --style=file --verbose -i " $@ " $ALL_FILES
3334 exit 0
3435fi
@@ -37,6 +38,10 @@ command -v docker >/dev/null 2>&1 || { echo >&2 "Please install docker. E.g., go
3738docker info > /dev/null 2>&1 || { echo >&2 " Docker server is not running? type 'docker info'." ; exit 1; }
3839
3940if [ -t 0 ]; then DOCKER_ARGS=-it; fi
40- docker pull kszonek/clang-format-17
4141
42- docker run --rm $DOCKER_ARGS -v " $MAINSOURCE " :" $MAINSOURCE " :Z -w " $MAINSOURCE " -u " $( id -u $USER ) :$( id -g $USER ) " kszonek/clang-format-17 --style=file --verbose -i " $@ " $ALL_FILES
42+ docker run --rm $DOCKER_ARGS \
43+ -v " $MAINSOURCE " :" $MAINSOURCE " :Z \
44+ -w " $MAINSOURCE " \
45+ -u " $( id -u $USER ) :$( id -g $USER ) " \
46+ " ghcr.io/jidicula/clang-format:$CLANG_FORMAT_MAJOR_VERSION " \
47+ --style=file --verbose -i " $@ " $ALL_FILES
0 commit comments