Skip to content
Permalink
Browse files

Tools/lint.sh: Look for specific versions of clang-format first

  • Loading branch information...
spycrab committed Mar 7, 2019
1 parent 533c3ab commit f43c6d68f2a28f477a81817e1e795d1336b71837
Showing with 9 additions and 3 deletions.
  1. +9 −3 Tools/lint.sh
@@ -11,8 +11,14 @@ fi

REQUIRED_CLANG_FORMAT_MAJOR=5
REQUIRED_CLANG_FORMAT_MINOR=0
CLANG_FORMAT=clang-format
CLANG_FORMAT_MAJOR=clang-format-${REQUIRED_CLANG_FORMAT_MAJOR}
CLANG_FORMAT_MAJOR_MINOR=${CLANG_FORMAT_MAJOR}.${REQUIRED_CLANG_FORMAT_MINOR}

if ! [ -x "$(command -v clang-format)" ]; then
if [ -x "$(command -v $CLANG_FORMAT_MAJOR)" ]; then CLANG_FORMAT=$CLANG_FORMAT_MAJOR; fi
if [ -x "$(command -v $CLANG_FORMAT_MAJOR_MINOR)" ]; then CLANG_FORMAT=$CLANG_FORMAT_MAJOR_MINOR; fi

if ! [ -x "$(command -v $CLANG_FORMAT)" ]; then
echo >&2 "error: clang-format is not installed"
echo >&2 "Install clang-format version ${REQUIRED_CLANG_FORMAT_MAJOR}.${REQUIRED_CLANG_FORMAT_MINOR}.*"
exit 1
@@ -30,7 +36,7 @@ if [ $# -gt 0 ]; then
fi

if [ $FORCE -eq 0 ]; then
CLANG_FORMAT_VERSION=$(clang-format -version | cut -d' ' -f3)
CLANG_FORMAT_VERSION=$($CLANG_FORMAT -version | cut -d' ' -f3)
CLANG_FORMAT_MAJOR=$(echo $CLANG_FORMAT_VERSION | cut -d'.' -f1)
CLANG_FORMAT_MINOR=$(echo $CLANG_FORMAT_VERSION | cut -d'.' -f2)

@@ -96,7 +102,7 @@ for f in ${modified_files}; do
fi

# Check for clang-format issues.
d=$(clang-format ${f} | (diff -u "${f}" - || true))
d=$($CLANG_FORMAT ${f} | (diff -u "${f}" - || true))
if ! [ -z "${d}" ]; then
echo "!!! ${f} not compliant to coding style, here is the fix:"
echo "${d}"

0 comments on commit f43c6d6

Please sign in to comment.
You can’t perform that action at this time.