Skip to content

Instantly share code, notes, and snippets.

@aikar
Created August 27, 2018 06:50
Show Gist options
  • Save aikar/0e8307645b10ca1eca9cadb95aaf6808 to your computer and use it in GitHub Desktop.
Save aikar/0e8307645b10ca1eca9cadb95aaf6808 to your computer and use it in GitHub Desktop.
#!/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
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