-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to automate checking out pull requests
- Loading branch information
Showing
1 changed file
with
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash -e | ||
|
||
if ! which jq > /dev/null; then exit $?; fi | ||
|
||
ME=$0 | ||
usage() { | ||
echo Usage: $ME "<pull request id>" | ||
echo | ||
exit 1 | ||
} | ||
|
||
[ -z "$PRID" ] && PRID=$1 | ||
[ -z "$PRID" ] && usage | ||
|
||
echo Fetching info for "PR#$PRID"... | ||
JSON=$(curl -s https://api.github.com/repos/arskom/spyne/pulls/$PRID) | ||
#JSON=$(cat pull.json) | ||
BRANCH=$(jq -r .head.ref <<< "$JSON") | ||
UPSTREAM=$(jq -r .head.repo.ssh_url <<< "$JSON") | ||
NAME=$(jq -r .head.user.login <<< "$JSON") | ||
|
||
# add remote | ||
if ! git remote get-url $NAME > /dev/null; then | ||
echo Add remote $NAME url: $UPSTREAM | ||
git remote add $NAME $UPSTREAM | ||
fi | ||
|
||
set -x | ||
git fetch -u $NAME $BRANCH:pr/$PRID | ||
git checkout pr/$PRID | ||
git branch -u $NAME/$BRANCH |