Skip to content

Instantly share code, notes, and snippets.

@ys
Created April 4, 2016 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ys/ad2be52913e65401840dbbe8261011cc to your computer and use it in GitHub Desktop.
Save ys/ad2be52913e65401840dbbe8261011cc to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
issue= ARGV.shift
current_branch = `git rev-parse --abbrev-ref HEAD`
default_branch = ENV.fetch("DEFAULT_BRANCH", "master")
origin_url = `git config --get remote.origin.url`
if origin_url.start_with?("git")
repo = origin_url.split(':')[1].split('.')[0]
else
repo = origin_url.sub('https://github.com/', '').split('.')[0]
end
command = "gh pull-request"
command = command + " -i #{issue}" if issue
command = command + " -b #{repo}:#{default_branch} -h #{repo}:#{current_branch}"
system command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment