Last active
November 18, 2015 21:24
-
-
Save simonrentzke/87c562b1ed8097205265 to your computer and use it in GitHub Desktop.
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 | |
# Dependencies | |
# - brew install hub | |
# - brew install ghi | |
# - ghi config --auth <gh username> | |
if ARGV.size != 1 | |
puts "USAGE: ./pr.rb <issue number>" | |
puts "\nFor Example:\n./pr.rb 1234" | |
exit | |
end | |
issue_number = ARGV[0] | |
# get current branch | |
current_branch = `git branch | sed -n '/\* /s///p'` | |
# push current branch to remote | |
puts 'Pushing to remote' | |
`git push --set-upstream origin #{current_branch}` | |
# send pull request for this branch | |
puts 'Sending pull request' | |
pull_request_url = `hub pull-request -f -m #{current_branch}` | |
pull_request_url_number = pull_request_url.split('/').last | |
# comment on the original gh issue | |
puts 'Commenting on GH issue' | |
`ghi comment -m \"#{pull_request_url}\" #{issue_number}` | |
# comment gh issue on the pr | |
puts 'Commenting on GH PR' | |
`ghi comment -m \"##{issue_number}\" #{pull_request_url_number}` | |
puts 'Done!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment