From 79f71ca2ef7121d827f06f356c4c0d2d6610bdf0 Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Sun, 27 Sep 2015 19:45:26 +0800 Subject: travis: fix Could not parse object TRAVIS_COMMIT If a PR is edited(e.g. force pushed) during the build. TRAVIS_COMMIT will be lost. Refetching the merge ref wouldn't help this situation as well. Since Travis already have reset $TRAVIS_BUILD_DIR to the commit we need to test, let's use it to determine TRAVIS_COMMIT directly. Ref: https://github.com/travis-ci/travis-ci/issues/2666 --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to '.travis.yml') diff --git a/.travis.yml b/.travis.yml index 3ac23cb2e..87b5fa217 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,14 +16,14 @@ matrix: rvm: system before_install: + - export TRAVIS_COMMIT=$(git rev-parse --verify -q HEAD) + - cd /usr/local - sudo rm -rf /usr/local/.git/refs /usr/local/.git/packed-refs - sudo rsync -az "$TRAVIS_BUILD_DIR/" /usr/local/ - export TRAVIS_BUILD_DIR="/usr/local" - sudo chown -R $USER /usr/local - - cd /usr/local - env | grep TRAVIS_ - if [ -f ".git/shallow" ]; then travis_retry git fetch --unshallow; fi - - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then git reset --hard $TRAVIS_COMMIT || travis_retry git fetch origin +refs/pull/$TRAVIS_PULL_REQUEST/merge:; fi - git reset --hard $TRAVIS_COMMIT - git clean -qxdff -- cgit v1.2.3