diff options
author | Heejin Ahn <aheejin@gmail.com> | 2019-04-30 17:12:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-30 17:12:36 -0700 |
commit | d77f0fdfb5f38b254a9382439a4961559b5d8cbe (patch) | |
tree | 08165e737bc8159e4027fdb4dae00107d469324f /clang-tidy-diff.sh | |
parent | a360a68b78248196b157ba6b950456d17d1b5190 (diff) | |
parent | a81f5cb4201a9569c80e101e5e86dcd7aa320943 (diff) | |
download | binaryen-d77f0fdfb5f38b254a9382439a4961559b5d8cbe.tar.gz binaryen-d77f0fdfb5f38b254a9382439a4961559b5d8cbe.tar.bz2 binaryen-d77f0fdfb5f38b254a9382439a4961559b5d8cbe.zip |
Add clang-tidy-diff hook to Travis CI (#2060)
This adds clang-tidy hook to Travis CI. This runs clang-tidy to the diff
between the current HEAD and master. (It takes very long time to run
clang-tidy on the whole repo, so it is not feasible anyway.)
Diffstat (limited to 'clang-tidy-diff.sh')
-rwxr-xr-x | clang-tidy-diff.sh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang-tidy-diff.sh b/clang-tidy-diff.sh new file mode 100755 index 000000000..931ad1a11 --- /dev/null +++ b/clang-tidy-diff.sh @@ -0,0 +1,13 @@ +#!/bin/bash +CLANG_DIR=$(dirname $(dirname $(which clang-tidy))) +CLANG_TIDY_DIFF=$CLANG_DIR/share/clang/clang-tidy-diff.py +MERGE_BASE=$(git merge-base master HEAD) +TIDY_MSG=$(git diff -U0 $MERGE_BASE | $CLANG_TIDY_DIFF -quiet -p1 2> /dev/null) +if [ -n "$TIDY_MSG" -a "$TIDY_MSG" != "No relevant changes found." ] +then + echo "Fix clang-tidy errors before committing!" + echo + # Run clang-tidy once again to show the error + git diff -U0 $MERGE_BASE | $CLANG_TIDY_DIFF -quiet -p1 + exit 1 +fi |