From 6431f9a751e2dfd68ef8b12b710e93c17b9327c7 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 15:46:41 -0700 Subject: [PATCH] Fixed issue with branch detection for PRs --- tests/ci_git_prep.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/ci_git_prep.sh b/tests/ci_git_prep.sh index b7ec8cf..64784e3 100755 --- a/tests/ci_git_prep.sh +++ b/tests/ci_git_prep.sh @@ -1,6 +1,27 @@ #!/bin/sh - +echo "Travis thinks the branch is $TRAVIS_BRANCH" git config --global user.email "travis@travis-ci.org" git config --global user.name "Travis CI" git checkout $TRAVIS_BRANCH exit 0 + + +git_setup() { + git config user.email "travis@travis-ci.org" + git config user.name "Travis CI" +} + +detect_branch() { + if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then + echo $TRAVIS_PULL_REQUEST_BRANCH + else + echo $TRAVIS_BRANCH + fi +} + +CURRENT_BRANCH=$(detect_branch) + +git_setup +git checkout $CURRENT_BRANCH +export $CURRENT_BRANCH +exit 0