Skip to content

Commit

Permalink
travis: fix Could not parse object TRAVIS_COMMIT
Browse files Browse the repository at this point in the history
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: travis-ci/travis-ci#2666
  • Loading branch information
xu-cheng committed Sep 28, 2015
1 parent 1b33c70 commit 79f71ca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 79f71ca

Please sign in to comment.