-
-
Save jcorcuera/f290ab1ff04cbdf9b3d3f855e4c8ac92 to your computer and use it in GitHub Desktop.
Github console helper. It opens project page, current issue, list of issues, pull request against specified branch.
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 | |
def open_project | |
puts "Openning project page" | |
`open #{project_url}` | |
end | |
def open_issue | |
return unless issue_number = branch_name.match(/\d+/)[0] | |
puts "Opening issue #{issue_number}" | |
issue_url = "#{project_url}/issues/#{issue_number}" | |
`open #{issue_url}` | |
end | |
def open_issues | |
puts "Opening issues" | |
issues_url = "#{project_url}/issues" | |
`open #{issues_url}` | |
end | |
def open_pull_request | |
puts "Opening PR..." | |
pull_request_url = "#{project_url}/compare/#{ARGV[1]}...#{branch_name}" | |
`open #{pull_request_url}` | |
end | |
def project_url | |
"https://github.com/#{repository_name}" | |
end | |
def repository_name | |
(`git remote show -n origin |grep Push`).match(/github\.[^:]+:(.*)\.git$/)[1] | |
end | |
def branch_name | |
`git rev-parse --abbrev-ref HEAD` | |
end | |
case ARGV.first | |
when nil | |
open_project | |
when 'i' | |
open_issue | |
when 'is' | |
open_issues | |
when 'pr' | |
open_pull_request | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment