Script for checking out pull request

I often have to test specific pull requests and tanks to this post on how to checkout git pull requests I was able to quickly bash together a script

I wrote this to ~/checkoutPR.sh

echo "Getting Pull request #$1"
git fetch origin pull/$1/head:pr-$1
git checkout pr-$1

then

chmod 775 ~/checkoutPR.sh

Then jump into the repo folder
Grab the Pull request # from the URL, replacing %pullrqeuestnumber% with the pull request #

~/checkoutPR.sh %pullrqeuestnumber%

Simple but useful.

The output is something like this

jose@debian:~/etherpad-lite$ ~/./checkoutPR.sh 1672
Getting Pull request #1672
remote: Counting objects: 142, done.
remote: Compressing objects: 100% (43/43), done.
remote: Total 124 (delta 101), reused 104 (delta 81)
Receiving objects: 100% (124/124), 13.58 KiB, done.
Resolving deltas: 100% (101/101), completed with 15 local objects.
From github.com:ether/etherpad-lite
 * [new branch]      refs/pull/1672/head -> pr-1672
Switched to branch 'pr-1672'

Leave a Reply

Your email address will not be published. Required fields are marked *