This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue where TRAVIS_BRANCH incorrectly specifies the branch name o…
…n PRs
- Loading branch information
1 parent
37094a7
commit d883ff6
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Return if we are not in a Pull Request | ||
[[ "$TRAVIS_PULL_REQUEST" = "false" ]] && return | ||
|
||
GITHUB_PR_URL=https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST | ||
GITHUB_PR_BODY=$(curl -s $GITHUB_PR_URL 2>/dev/null) | ||
echo $GITHUB_PR_BODY | ||
|
||
if [[ $GITHUB_PR_BODY =~ \"ref\":\ *\"([a-zA-Z0-9_-]*)\" ]]; then | ||
export TRAVIS_PR_BRANCH=${BASH_REMATCH[1]} | ||
echo $TRAVIS_PR_BRANCH | ||
else | ||
return | ||
fi | ||
|
||
GITHUB_BRANCH_URL=https://api.github.com/repos/$TRAVIS_REPO_SLUG/branches/$TRAVIS_PR_BRANCH | ||
echo $GITHUB_BRANCH_URL | ||
if [ $(curl -s --head --request GET $GITHUB_BRANCH_URL | grep "200 OK" > /dev/null) ]; then | ||
TRAVIS_BRANCH=$TRAVIS_PR_BRANCH | ||
echo $TRAVIS_BRANCH | ||
if [[ $GITHUB_PR_BODY =~ \"repo\":.*\"clone_url\":\ *\"https://github\.com/([a-zA-Z0-9_-]*/[a-zA-Z0-9_-]*)\.git.*\"base\" ]]; then | ||
export TRAVIS_REPO_SLUG=${BASH_REMATCH[1]} | ||
fi | ||
fi |