Skip to content

Instantly share code, notes, and snippets.

@simonrentzke
Last active November 18, 2015 21:24
Show Gist options
  • Save simonrentzke/87c562b1ed8097205265 to your computer and use it in GitHub Desktop.
Save simonrentzke/87c562b1ed8097205265 to your computer and use it in GitHub Desktop.
#!/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