diff --git a/.clang_format.hook b/.clang_format.hook index 9db4fe4550c44fdb60e48818841d99ba5a081f46..40d70f56cf97f7b7f18bb255dae73ab1d542f12a 100755 --- a/.clang_format.hook +++ b/.clang_format.hook @@ -1,5 +1,15 @@ -#!/bin/bash +#!/usr/bin/env bash +set -e -# clang-format hook without version check +readonly VERSION="3.8" + +version=$(clang-format -version) + +if ! [[ $version == *"$VERSION"* ]]; then + echo "clang-format version check failed." + echo "a version contains '$VERSION' is needed, but get '$version'" + echo "you can install the right version, and make an soft-link to '\$PATH' env" + exit -1 +fi clang-format $@