Skip to content

Commit 130cd28

Browse files
ammaraskarmiss-islington
authored andcommitted
Fix changed file detection on Travis (pythonGH-3129)
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-workflowGH-14 (cherry picked from commit b2ec361)
1 parent d7274c6 commit 130cd28

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

.travis.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,21 @@ matrix:
6666
before_script:
6767
- |
6868
set -e
69-
if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.rst$)|(^Doc)|(^Misc)'
69+
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
70+
files_changed=$(git diff --name-only $TRAVIS_COMMIT_RANGE)
71+
else
72+
# Pull requests are slightly complicated because merging the PR commit without
73+
# rebasing causes it to retain its old commit date. Meaning in history if any
74+
# commits have been made on master that post-date it, they will be accidentally
75+
# included in the diff if we use the TRAVIS_COMMIT_RANGE variable.
76+
files_changed=$(git diff --name-only HEAD $(git merge-base HEAD $TRAVIS_BRANCH))
77+
fi
78+
79+
# Prints changed files in this commit to help debug doc-only build issues.
80+
echo "Files changed: "
81+
echo $files_changed
82+
83+
if ! echo $files_changed | grep -qvE '(\.rst$)|(^Doc)|(^Misc)'
7084
then
7185
echo "Only docs were updated, stopping build process."
7286
exit

0 commit comments

Comments
 (0)