Commit 9df1e19f authored by Simon Spannagel's avatar Simon Spannagel
Browse files

git hooks: allow for newer clang-format versions

parent 6fe531ca
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -69,13 +69,14 @@ if [ ! -x "$CLANG_FORMAT" ] ; then
    exit 1
fi

if ! "$CLANG_FORMAT" --version | grep "clang-format version $CLANG_FORMAT_VERSION" >/dev/null 2>/dev/null; then
CLANG_FORMAT_VERSION_FOUND=`"$CLANG_FORMAT" --version | sed -n "s/.* \([0-9]\+\)\.[0-9]\+\.[0-9]\+.*/\1/p"`
if [ "${CLANG_FORMAT_VERSION_FOUND}" -lt "${CLANG_FORMAT_VERSION}" ]; then
    # Be indulgent with OSX users, no 4.0 seems to be available...
    if [ "$OSTYPE" != "darwin"* ]; then
        printf "Error: clang-format version $CLANG_FORMAT_VERSION is required (exactly), cannot check format!\n"
        printf "Error: clang-format version $CLANG_FORMAT_VERSION or newer is required, cannot check format!\n"
        exit 1
    else
        printf "Warning: clang-format version $CLANG_FORMAT_VERSION is required, formatting might be incompatible!\n"
        printf "Warning: clang-format version $CLANG_FORMAT_VERSION or newer is required, formatting might be incompatible!\n"
    fi
fi