Created
August 27, 2018 13:57
-
-
Save aikar/0ccc0e17b87272a863a16048dfa16585 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
if [ -z "$1" ]; then | |
echo "$0 <prID>" | |
exit 1; | |
fi | |
curl -q https://api.github.com/repos/PaperMC/Paper/pulls/$1 2>/dev/null > /tmp/pr | |
url=$(grep --color=none ssh_url /tmp/pr | head -n 1 |awk '{print $2}' | sed 's/"//g' | sed 's/,//g') | |
ref=$(grep --color=none '"head":' -A 3 /tmp/pr | grep ref | head -n 1 |awk '{print $2}' | sed 's/"//g' | sed 's/,//g') | |
branch="pr/$1" | |
up="pr-$1" | |
git remote remove -f $up 2>&1 1>/dev/null | |
git remote add -f $up $url | |
git fetch $up | |
git checkout -b $branch $up/$ref || true | |
echo "Dropping to new shell, exit to delete the refs" | |
bash -i | |
echo "Deleting branch/upstream" | |
git branch -D $branch | |
git remote rm -f $up | |
git gc | |
#git branch -u $up/$ref $branch | |
#git checkout $branch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment