[Python-checkins] Fix changed file detection on Travis (GH-3129)

Berker Peksag webhook-mailer at python.org
Sat Jan 27 17:48:12 EST 2018


https://github.com/python/cpython/commit/4d2dd64471c5047fe4aa24fb407e9d855344388e
commit: 4d2dd64471c5047fe4aa24fb407e9d855344388e
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Berker Peksag <berker.peksag at gmail.com>
date: 2018-01-28T01:48:09+03:00
summary:

Fix changed file detection on Travis (GH-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-workflow#14

(cherry picked from commit b2ec3615c81ca4f3c938245842a45956da8d5acb)

files:
M .travis.yml

diff --git a/.travis.yml b/.travis.yml
index e624092bba36..d568534929ad 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -66,7 +66,21 @@ matrix:
 before_script:
   - |
       set -e
-      if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.rst$)|(^Doc)|(^Misc)'
+      if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
+        files_changed=$(git diff --name-only $TRAVIS_COMMIT_RANGE)
+      else
+        # Pull requests are slightly complicated because merging the PR commit without
+        # rebasing causes it to retain its old commit date. Meaning in history if any
+        # commits have been made on master that post-date it, they will be accidentally
+        # included in the diff if we use the TRAVIS_COMMIT_RANGE variable.
+        files_changed=$(git diff --name-only HEAD $(git merge-base HEAD $TRAVIS_BRANCH))
+      fi
+
+      # Prints changed files in this commit to help debug doc-only build issues.
+      echo "Files changed: "
+      echo $files_changed
+
+      if ! echo $files_changed | grep -qvE '(\.rst$)|(^Doc)|(^Misc)'
       then
         echo "Only docs were updated, stopping build process."
         exit



More information about the Python-checkins mailing list