Meta: Warn before attempting to use clang-format 19

The clang-format version released with llvm 19 will format many files
differently than clang-format-18.

This change presents the existing warning shown for incorrect
clang-format versions to those with versions greater than 18.

Fixes issue #1750
This commit is contained in:
John Diamond 2024-10-12 22:47:19 +02:00 committed by Andrew Kaster
parent 10a2cc3781
commit 8f45f59df3
Notes: github-actions[bot] 2024-10-14 21:55:58 +00:00

View file

@ -39,13 +39,13 @@ if (( ${#files[@]} )); then
CLANG_FORMAT=$TOOLCHAIN_DIR/clang-format
elif command -v clang-format >/dev/null 2>&1 ; then
CLANG_FORMAT=clang-format
if ! "${CLANG_FORMAT}" --version | awk '{ if (substr($NF, 1, index($NF, ".") - 1) < 18) exit 1; }'; then
echo "You are using '$("${CLANG_FORMAT}" --version)', which appears to not be clang-format 18 or later."
if ! "${CLANG_FORMAT}" --version | awk '{ if (substr($NF, 1, index($NF, ".") - 1) != 18) exit 1; }'; then
echo "You are using '$("${CLANG_FORMAT}" --version)', which appears to not be clang-format 18."
echo "It is very likely that the resulting changes are not what you wanted."
fi
else
echo "clang-format-18 is not available, but C or C++ files need linting! Either skip this script, or install clang-format-18."
echo "(If you install a package 'clang-format', please make sure it's version 18 or later.)"
echo "(If you install a package 'clang-format', please make sure it's version 18.)"
exit 1
fi