Our team uses Github’s pull requests as a code review process, which requires a fair number of requests that need to be tested. Github has a really cool feature where if you put the .patch extension to the url it will show you a diff that can be passed to git am.
So given a pull request 162 (https://github.com/candlepin/candlepin/pull/162) you can use curl to download the patch and then pipe it to git am. Once you’re done reviewing, simply revert your branch back using git reset --hard origin/master.
I added some functions to my .bashrc for the projects I review most often, here’s the snippet:
# apply the given pull request from the given project as a patch
# arg: project (i.e. candlepin/subscription-manager/etc
# arg: pull request number
__github ()
{
curl https://github.com/candlepin/$1/pull/$2.patch | git am
}
# apply the given pull request for candlepin
# arg: pull request number
cppull ()
{
__github "candlepin" $1
}
# apply the given pull request for subscription-manager
# arg: pull request number
submanpull ()
{
__github "subscription-manager" $1
}
Summary
curl https://github.com/candlepin/candlepin/162.patch | git am- TEST PATCH
git reset --hard origin/master
You can do a similar thing with git aliases, which allow you to run shell commands using what looks like a git command, like `git cppull 4`:
http://stackoverflow.com/questions/1309430/how-to-embed-bash-script-directly-inside-a-git-alias
There are a ton of really slick aliases available that can change the way you work with git:
https://git.wiki.kernel.org/index.php/Aliases
Definitely interesting and I have been doing this for a while, but why not to do what github.com says in the mail
git checkout -b temp
git pull https://github.com/parthaa/katello runcible-0.3.2-changes
# review time!
git branch -D temp
Advantage of this is you can stop your review and get back to it easily later.