diff --git a/.travis.yml b/.travis.yml index 5f84e2da9dd..f0e80827366 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,9 @@ jobs: clang-format-7 --version # build a pathspec that excludes the files in .clang-format-ignore while read file ; do echo EXCLUDES+="':(top,exclude)$file' " ; done < .clang-format-ignore - git-clang-format-7 --binary clang-format-7 "${TRAVIS_BRANCH}" -- $EXCLUDES + MERGE_BASE=$(git merge-base ${TRAVIS_COMMIT_RANGE%...*} ${TRAVIS_COMMIT_RANGE#*...}) + echo "Checking for formatting errors introduced since $MERGE_BASE" + git-clang-format-7 --binary clang-format-7 $MERGE_BASE -- $EXCLUDES git diff > formatted.diff if [[ -s formatted.diff ]] ; then echo 'Formatting error! The following diff shows the required changes' diff --git a/scripts/travis_lint.sh b/scripts/travis_lint.sh index 6592a3ebdfa..f7b80ed9327 100755 --- a/scripts/travis_lint.sh +++ b/scripts/travis_lint.sh @@ -12,5 +12,6 @@ else git config remote.origin.fetch +refs/heads/$TRAVIS_BRANCH:refs/remotes/origin/$TRAVIS_BRANCH git fetch --unshallow git checkout $TMP_HEAD - $script_folder/run_diff.sh CPPLINT origin/$TRAVIS_BRANCH # Check for errors compared to merge target + MERGE_BASE=$(git merge-base ${TRAVIS_COMMIT_RANGE%...*} ${TRAVIS_COMMIT_RANGE#*...}) + $script_folder/run_diff.sh CPPLINT $MERGE_BASE fi