Skip to content

Commit ba23989

Browse files
authored
Merge pull request #4740 from tautschnig/use-travis-commit-range
Travis clang-format, cpplint: Use the merge base
2 parents 022c79e + 59baaab commit ba23989

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ jobs:
1818
clang-format-7 --version
1919
# build a pathspec that excludes the files in .clang-format-ignore
2020
while read file ; do echo EXCLUDES+="':(top,exclude)$file' " ; done < .clang-format-ignore
21-
git-clang-format-7 --binary clang-format-7 "${TRAVIS_BRANCH}" -- $EXCLUDES
21+
MERGE_BASE=$(git merge-base ${TRAVIS_COMMIT_RANGE%...*} ${TRAVIS_COMMIT_RANGE#*...})
22+
echo "Checking for formatting errors introduced since $MERGE_BASE"
23+
git-clang-format-7 --binary clang-format-7 $MERGE_BASE -- $EXCLUDES
2224
git diff > formatted.diff
2325
if [[ -s formatted.diff ]] ; then
2426
echo 'Formatting error! The following diff shows the required changes'

scripts/travis_lint.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ else
1212
git config remote.origin.fetch +refs/heads/$TRAVIS_BRANCH:refs/remotes/origin/$TRAVIS_BRANCH
1313
git fetch --unshallow
1414
git checkout $TMP_HEAD
15-
$script_folder/run_diff.sh CPPLINT origin/$TRAVIS_BRANCH # Check for errors compared to merge target
15+
MERGE_BASE=$(git merge-base ${TRAVIS_COMMIT_RANGE%...*} ${TRAVIS_COMMIT_RANGE#*...})
16+
$script_folder/run_diff.sh CPPLINT $MERGE_BASE
1617
fi

0 commit comments

Comments
 (0)