Allow clang-format 12 in the pre-commit hook

clang-format 12's formatting is identical to clang-format 11's.

(cherry picked from commit d74413ebd0)
This commit is contained in:
Hugo Locurcio 2021-06-07 16:59:52 +02:00 committed by Rémi Verschelde
parent fab9c19d2e
commit 5738d6ee6e
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 4 additions and 3 deletions

View File

@ -76,7 +76,8 @@ fi
# To get consistent formatting, we recommend contributors to use the same # To get consistent formatting, we recommend contributors to use the same
# clang-format version as CI. # clang-format version as CI.
RECOMMENDED_CLANG_FORMAT_MAJOR="11" RECOMMENDED_CLANG_FORMAT_MAJOR_MIN="11"
RECOMMENDED_CLANG_FORMAT_MAJOR_MAX="12"
if [ ! -x "$CLANG_FORMAT" ] ; then if [ ! -x "$CLANG_FORMAT" ] ; then
message="Error: clang-format executable not found. Please install clang-format $RECOMMENDED_CLANG_FORMAT_MAJOR.x.x." message="Error: clang-format executable not found. Please install clang-format $RECOMMENDED_CLANG_FORMAT_MAJOR.x.x."
@ -106,8 +107,8 @@ fi
CLANG_FORMAT_VERSION="$(clang-format --version | sed "s/[^0-9\.]*\([0-9\.]*\).*/\1/")" CLANG_FORMAT_VERSION="$(clang-format --version | sed "s/[^0-9\.]*\([0-9\.]*\).*/\1/")"
CLANG_FORMAT_MAJOR="$(echo "$CLANG_FORMAT_VERSION" | cut -d. -f1)" CLANG_FORMAT_MAJOR="$(echo "$CLANG_FORMAT_VERSION" | cut -d. -f1)"
if [ "$CLANG_FORMAT_MAJOR" != "$RECOMMENDED_CLANG_FORMAT_MAJOR" ]; then if [[ "$CLANG_FORMAT_MAJOR" -lt "$RECOMMENDED_CLANG_FORMAT_MAJOR_MIN" || "$CLANG_FORMAT_MAJOR" -gt "$RECOMMENDED_CLANG_FORMAT_MAJOR_MAX" ]]; then
echo "Warning: Your clang-format binary is the wrong version ($CLANG_FORMAT_VERSION, expected $RECOMMENDED_CLANG_FORMAT_MAJOR.x.x)." echo "Warning: Your clang-format binary is the wrong version ($CLANG_FORMAT_VERSION, expected between $RECOMMENDED_CLANG_FORMAT_MAJOR_MIN.x.x and $RECOMMENDED_CLANG_FORMAT_MAJOR_MAX.x.x)."
echo " Consider upgrading or downgrading clang-format as formatting may not be applied correctly." echo " Consider upgrading or downgrading clang-format as formatting may not be applied correctly."
fi fi