Skip to content

Commit df65aff

Browse files
committed
Fix changed file detection on travis when the PR commits predate master commits.
Travis when merging changes from a pull request onto the target branch does not perform a rebase, instead it does a simple merge which causes the PR commits to retain their commit dates. This means that the commit log can potentially look like: PR merge <-- HEAD normal master commit <- master more commits from normal workflow PR commit 1 another master commit PR commit 2 Performing a git diff from PR commit 2 to master will accidentally include files that should not be there. Closes python/core-workflow#14
1 parent 29a7df7 commit df65aff

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

.travis.yml

+14-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,20 @@ matrix:
8383
before_script:
8484
- |
8585
set -e
86-
if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.rst$)|(^Doc)|(^Misc)'
86+
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
87+
files_changed=$(git diff --name-only $TRAVIS_COMMIT_RANGE)
88+
else
89+
# Pull requests are slightly complicated because merging the PR commit without
90+
# rebasing causes it to retain its old commit date. Meaning in history if any
91+
# commits have been made on master that post-date it, they will be accidentally
92+
# included in the diff if we use the simple TRAVIS_COMMIT_RANGE method
93+
files_changed=$(git diff --name-only HEAD $(git merge-base HEAD $TRAVIS_BRANCH))
94+
fi
95+
96+
echo "files_changed: "
97+
echo $files_changed
98+
99+
if ! echo $files_changed | grep -qvE '(\.rst$)|(^Doc)|(^Misc)'
87100
then
88101
echo "Only docs were updated, stopping build process."
89102
exit

0 commit comments

Comments
 (0)