Sha256: 643ef244a297bbe712132846cfa209e12750dd728c6645fa0a27202bc3564370

Contents?: true

Size: 1.84 KB

Versions: 2

Compression:

Stored size: 1.84 KB

Contents

#!/usr/bin/env ruby
#
# git-pull-request --
# 
#   Open a pull request for the current branch in your default browser
# 
# Copyright (C) 2012 Julien Letessier
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
require 'CGI'

origin_url = `git config --get remote.origin.url`.strip
unless origin_url =~ /github\.com/
  puts "origin does not have a Github URL !"
  exit 1
end

repo = origin_url.sub(/.*github\.com[\/:]/,'').sub(/\.git$/,'')

if ARGV[0]
  branch = ARGV[0]
else
  branch = `git symbolic-ref HEAD`.gsub(%r(^refs/heads/), "")
  exit $? unless $? == 0
end

if branch == 'master'
  puts "You cannot issue a pull request for master !"
  exit 1
end

against = ARGV[1] || 'master'

url = "https://github.com/#{repo}/pull/new?base_repo=#{CGI.escape(repo)}&base_ref=#{against}&head_ref=#{branch}"
puts "Preparing a pull request for branch #{branch}"
system "open", url

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
git-whistles-0.3.1 bin/git-pull-request
git-whistles-0.3.0 bin/git-pull-request