From df65aff65f712cee0eb7341d13389e4e7bccba36 Mon Sep 17 00:00:00 2001 From: Ammar Askar Date: Fri, 26 Jan 2018 18:50:32 -0500 Subject: [PATCH 1/3] 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 --- .travis.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 687d0214ab8f37..87b44c82bd3927 100644 --- a/.travis.yml +++ b/.travis.yml @@ -83,7 +83,20 @@ 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 simple TRAVIS_COMMIT_RANGE method + files_changed=$(git diff --name-only HEAD $(git merge-base HEAD $TRAVIS_BRANCH)) + fi + + 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 From eece65717115a1aee404670292ee07dcd2ecfe43 Mon Sep 17 00:00:00 2001 From: Ammar Askar Date: Fri, 26 Jan 2018 20:11:08 -0500 Subject: [PATCH 2/3] Fix up comments in the travis file --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 87b44c82bd3927..38fcaf22d2a63b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -89,11 +89,12 @@ before_script: # 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 simple TRAVIS_COMMIT_RANGE method + # 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 - echo "files_changed: " + # 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)' From ef6f8e8dad2660c6dea48b7963d54f141bc5c701 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Sat, 27 Jan 2018 21:29:29 +0300 Subject: [PATCH 3/3] Fix typo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 38fcaf22d2a63b..d7387e5f9831b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -94,7 +94,7 @@ before_script: fi # Prints changed files in this commit to help debug doc-only build issues. - echo "Files_changed: " + echo "Files changed: " echo $files_changed if ! echo $files_changed | grep -qvE '(\.rst$)|(^Doc)|(^Misc)'