Skip to content

Commit a71b440

Browse files
jmikoladerickr
authored andcommitted
PHPC-1118: Require clang-format >= 6.0.0
1 parent 125c99f commit a71b440

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

scripts/clang-format.sh

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,23 @@ if test x"$1" = xchanged; then
1313
fi
1414

1515
# Find clang-format, we prefer -6.0, but also allow binaries without -suffix as
16-
# long as they're 6.0.0
17-
CLANG_FORMAT=
16+
# long as they're >= 6.0.0
17+
CLANG_FORMAT=`which clang-format-6.0`
1818

19-
which clang-format-6.0
20-
if [ $? = 0 ]; then
21-
CLANG_FORMAT=`which clang-format-6.0`
19+
if [ -z "$CLANG_FORMAT" ]; then
20+
CLANG_FORMAT=`which clang-format`
2221
fi
2322

24-
which clang-format
25-
if [ $? = 0 ]; then
26-
VERSION=`clang-format -version | cut -d " " -f 3 | cut -c 1-3`
27-
if [ x"$VERSION" = "x6.0" ]; then
28-
CLANG_FORMAT=`which clang-format`
29-
fi
23+
if [ -z "$CLANG_FORMAT" ]; then
24+
echo "Couldn't find clang-format"
25+
exit
3026
fi
3127

32-
if [ x"$CLANG_FORMAT" = "x" ]; then
33-
echo "Couldn't find the right clang-format (needs version 6.0)"
28+
VERSION=`$CLANG_FORMAT -version | cut -d " " -f 3`
29+
VERSION_MAJOR=`echo $VERSION | cut -d "." -f 1`
30+
31+
if [ $VERSION_MAJOR -lt 6 ]; then
32+
echo "Found clang-format $VERSION but we need >= 6.0.0"
3433
exit
3534
fi
3635

0 commit comments

Comments
 (0)