diff options
author | yenatch <yenatch@gmail.com> | 2017-06-22 20:09:35 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-22 20:09:35 -0400 |
commit | effc14bdc9b52f1075f36c207c459689bbe18d79 (patch) | |
tree | 8a35fb5cd825c17a4f28186222213fab41e867de /.travis/check-git-clang-format-output.sh | |
parent | 42ae04c74fe07d05175efb4df143dbcf1b2752bc (diff) | |
parent | c14b7b8d913e2917cdb5234680162a70965f41d0 (diff) |
Merge pull request #337 from marijnvdwerf/clean/clang-format-ci
Run clang-format on CI
Diffstat (limited to '.travis/check-git-clang-format-output.sh')
-rwxr-xr-x | .travis/check-git-clang-format-output.sh | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/.travis/check-git-clang-format-output.sh b/.travis/check-git-clang-format-output.sh new file mode 100755 index 000000000..c53efa726 --- /dev/null +++ b/.travis/check-git-clang-format-output.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ "$TRAVIS_PULL_REQUEST" == "false" ] ; then + # Not in a pull request, so compare against parent commit + base_commit="HEAD^" + echo "Running clang-format against parent commit $(git rev-parse $base_commit)" +else + base_commit="$TRAVIS_BRANCH" + echo "Running clang-format against branch $base_commit, with hash $(git rev-parse $base_commit)" +fi + +output="$(.travis/git-clang-format --binary clang-format-5.0 --commit $base_commit --diff)" + +if [ "$output" == "no modified files to format" ] || [ "$output" == "clang-format did not modify any files" ] ; then + echo "clang-format passed." + exit 0 +else + echo "clang-format failed:" + echo "$output" | colordiff + exit 1 +fi |