Skip to content

Instantly share code, notes, and snippets.

@maxehmookau
Created March 17, 2013 11:56
Show Gist options
  • Save maxehmookau/5181241 to your computer and use it in GitHub Desktop.
Save maxehmookau/5181241 to your computer and use it in GitHub Desktop.
Make a pull request from your current branch in to the repo's master branch.
def get_current_branch
b = `git branch`.split("\n").delete_if { |i| i[0] != "*" }
current_branch = b.first.split(" ").last
end
def get_origin_remote
`git remote -v`.split("\n").delete_if { |i| i[0..5] != 'origin' }.first
end
def get_github_username
get_origin_remote.split(':')[1].split('/').first
end
def get_repo_name
get_origin_remote.split('/')[1].split('.git').first
end
def get_pull_request_uri
"https://github.com/#{ get_github_username }/#{ get_repo_name }/pull/new/#{ get_github_username }:master...#{ get_github_username }:#{ get_current_branch }"
end
puts get_pull_request_uri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment