From a628a9b4da18dc466997bfbc89810c86a262416b Mon Sep 17 00:00:00 2001 From: Mingshen Sun Date: Thu, 18 Jul 2019 13:09:10 -0700 Subject: [PATCH] Properly get the commit range for cache --- .travis.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7084622..2707609 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,16 @@ install: - pod --version before_script: - pod install + - git diff --quiet "$TRAVIS_COMMIT_RANGE" -- ; GIT_DIFF_EXIT_CODE=$? - | - if [ ! $(git diff --name-only master..."$TRAVIS_COMMIT" | grep "Cartfile.resolved") ] && [ -d "Carthage/Build" ]; then + if [ "$GIT_DIFF_EXIT_CODE" -gt 1 ] ; then + git remote set-branches --add origin master + git fetch + TRAVIS_COMMIT_RANGE=origin/master... + fi + - echo $TRAVIS_COMMIT_RANGE + - | + if [ ! $(git diff --name-only "$TRAVIS_COMMIT_RANGE" | grep "Cartfile.resolved") ] && [ -d "Carthage/Build" ]; then echo "Use cached carthage dependencies." ls -ld Carthage/Build/iOS/*framework else @@ -23,7 +31,7 @@ before_script: travis_wait 45 carthage bootstrap --platform iOS fi - | - if [ ! $(git diff --name-only master..."$TRAVIS_COMMIT" | grep -E "gopenpgp_build.sh|gopenpgpwrapper.go") ] && [ -d "go/dist/Gopenpgpwrapper.framework" ]; then + if [ ! $(git diff --name-only "$TRAVIS_COMMIT_RANGE" | grep -E "gopenpgp_build.sh|gopenpgpwrapper.go") ] && [ -d "go/dist/Gopenpgpwrapper.framework" ]; then echo "Use cached go dependencies." ls -ld go/dist/*framework else