diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2021-06-07 17:53:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-07 17:53:45 +0200 |
commit | 6f8d5cff66416993856bdb01c83b999b84425fb0 (patch) | |
tree | 183f1e29729a4393842d0f9fc1b1cd0b04b6716c | |
parent | d10ace8870a298faa4b5c9e6b0ea851372e8a7ff (diff) | |
parent | d74413ebd006a776c87c0b00f4a265e347df87ff (diff) |
Merge pull request #49390 from Calinou/pre-commit-allow-clang-format-12
Allow clang-format 12 in the pre-commit hook
-rwxr-xr-x | misc/hooks/pre-commit-clang-format | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/misc/hooks/pre-commit-clang-format b/misc/hooks/pre-commit-clang-format index 2dac8e9a55..81bc412944 100755 --- a/misc/hooks/pre-commit-clang-format +++ b/misc/hooks/pre-commit-clang-format @@ -76,7 +76,8 @@ fi # To get consistent formatting, we recommend contributors to use the same # 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 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_MAJOR="$(echo "$CLANG_FORMAT_VERSION" | cut -d. -f1)" -if [ "$CLANG_FORMAT_MAJOR" != "$RECOMMENDED_CLANG_FORMAT_MAJOR" ]; then - echo "Warning: Your clang-format binary is the wrong version ($CLANG_FORMAT_VERSION, expected $RECOMMENDED_CLANG_FORMAT_MAJOR.x.x)." +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 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." fi |