Skip to content

Instantly share code, notes, and snippets.

@jimweirich
Created May 5, 2013 00:51
Show Gist options
  • Save jimweirich/5519290 to your computer and use it in GitHub Desktop.
Save jimweirich/5519290 to your computer and use it in GitHub Desktop.
Script I use to pull in pull requests from GitHub
#!/usr/bin/ruby -wKU
if ARGV.empty?
puts "Usage: pullrequest user:branch"
exit 1
end
url = `git config --get remote.origin.url`
unless %r{([^/]+)\.git$} =~ url
puts "Unable to determine repo from url (#{url})"
exit 1
end
repo = $1
user, branch = ARGV.first.split(/:/)
system "git pull https://github.com/#{user}/#{repo}.git #{branch}"
@jimweirich
Copy link
Author

A pull request from github comes with user name and remote branch in the form user:branch (e.g. randycoulman:default-thread-pool-size). Copy the user:branch into your paste buffer. Then in your local repot do:

$ git checkout -b my-branch   # use whatever temp branch name you wish, it doesn't matter
$ pullrequest user:branch     # paste user:branch from the github pull request

At this point, the pull request will be in your local branch. Check it out, run the tests and see if everything is ok. If you like the result, merge my-branch into master and push to github. If you don't like the changes, delete the branch and ask the pull requester to make improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment