From 7c0297abe8f4fb4aafd642c3130628185dc78978 Mon Sep 17 00:00:00 2001 From: Petri Lehtinen Date: Thu, 17 Oct 2019 11:41:16 +0300 Subject: [PATCH] Support running a specific clang-format version in CI --- .travis.yml | 2 +- scripts/clang-format-ci | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a6c9054..df74eb2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,4 +29,4 @@ script: - if [ "$JANSSON_BUILD_METHOD" = "cmake" ]; then mkdir build && cd build && cmake $JANSSON_CMAKE_OPTIONS .. && cmake --build . && ctest --output-on-failure; fi - if [ "$JANSSON_BUILD_METHOD" = "coverage" ]; then mkdir build && cd build && cmake $JANSSON_CMAKE_OPTIONS .. && cmake --build . && cmake --build . --target coveralls; fi - if [ "$JANSSON_BUILD_METHOD" = "fuzzer" ]; then ./test/ossfuzz/travisoss.sh; fi - - if [ "$JANSSON_BUILD_METHOD" = "lint" ]; then ./scripts/clang-format-ci; fi + - if [ "$JANSSON_BUILD_METHOD" = "lint" ]; then ./scripts/clang-format-ci 9; fi diff --git a/scripts/clang-format-ci b/scripts/clang-format-ci index 2051262..6854fc2 100755 --- a/scripts/clang-format-ci +++ b/scripts/clang-format-ci @@ -1,10 +1,15 @@ #!/bin/bash +clangformat="clang-format" +if [ -n "$1" ]; then + clangformat="clang-format-$1" +fi + errors=0 paths=$(find . -type f -a '(' -name '*.c' -o -name '*.h' ')') for path in $paths; do in=$(cat $path) - out=$(clang-format $path) + out=$($clangformat $path) if [ "$in" != "$out" ]; then diff -u -L $path -L "$path.formatted" $path - <<<$out