Skip to content

Instantly share code, notes, and snippets.

@laginha87
Created January 10, 2017 09:34
Show Gist options
  • Save laginha87/f9d49c93d0e8d9006763e72c1bcffbba to your computer and use it in GitHub Desktop.
Save laginha87/f9d49c93d0e8d9006763e72c1bcffbba to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Needs https://github.com/schacon/git-pulls to work
current_branch = %x(git rev-parse --abbrev-ref HEAD).sub("\n","")
repo_url = %x(git config --get remote.origin.url).sub(".git\n", '')
%x(git pulls update)
pull_requests = %x(git pulls list)
possible_pull_request = pull_requests.split("\n").grep(Regexp.new(current_branch))
has_pull_request = !possible_pull_request.empty?
if(has_pull_request)
pull_request_num = possible_pull_request.first.split(' ').first
puts "Current Pull Request is: #{repo_url}/pull/#{pull_request_num}"
else
puts "Create a New Pull request: #{repo_url}/compare/#{current_branch}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment