Skip to content

Commit

Permalink
Merge pull request #5896 from beholdnec/lint-version-checks
Browse files Browse the repository at this point in the history
Tools: Check for git and clang-format version 3.8.x in lint.sh
  • Loading branch information
leoetlino committed Aug 22, 2017
2 parents 788af71 + f9b8365 commit e3fff35
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Tools/lint.sh
Expand Up @@ -4,6 +4,43 @@

set -euo pipefail

if ! [ -x "$(command -v git)" ]; then
echo >&2 "error: git is not installed"
exit 1
fi

REQUIRED_CLANG_FORMAT_MAJOR=3
REQUIRED_CLANG_FORMAT_MINOR=8

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
fi

FORCE=0

if [ $# -gt 0 ]; then
case "$1" in
-f|--force)
FORCE=1
shift
;;
esac
fi

if [ $FORCE -eq 0 ]; then
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)

if [ $CLANG_FORMAT_MAJOR != $REQUIRED_CLANG_FORMAT_MAJOR ] || [ $CLANG_FORMAT_MINOR != $REQUIRED_CLANG_FORMAT_MINOR ]; then
echo >&2 "error: clang-format is the wrong version (${CLANG_FORMAT_VERSION})"
echo >&2 "Install clang-format version ${REQUIRED_CLANG_FORMAT_MAJOR}.${REQUIRED_CLANG_FORMAT_MINOR}.* or use --force to ignore"
exit 1
fi
fi

fail=0

# Default to staged files, unless a commit was passed.
Expand Down

0 comments on commit e3fff35

Please sign in to comment.