Created
December 5, 2014 17:25
-
-
Save shinypb/7d6014025cb7be2484d0 to your computer and use it in GitHub Desktop.
Create GitHub pull request from the command line
This file contains 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
#!/usr/bin/env ruby | |
remote_url = `git config --get remote.origin.url`.strip | |
matches = remote_url.match(/github\.com:(.+)\/(.+)\.git/) | |
if matches | |
branch_name = `git rev-parse --abbrev-ref HEAD`.strip | |
exec "open https://github.com/#{matches[1]}/#{matches[2]}/compare/#{branch_name}?expand=1" | |
end | |
# Save this file as ~/bin/git-pr and then `chmod +x ~/bin/git-pr`. | |
# Then, you can create a pull request for your current branch by typing `git pr`. Woohoo! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This looks safer (in case the matches have unexpected, evil characters):
From http://www.ruby-doc.org/core-2.1.5/Kernel.html#method-i-exec :