Class: Git::Whistles::PullRequest::Bare
- Defined in:
- lib/git-whistles/pull_request/bare.rb
Constant Summary collapse
- BROWSERS =
%w(xdg-open open firefox iceweasel)- SAFE_QUERY_STRING_SIZE =
8000
Instance Method Summary collapse
-
#initialize ⇒ Bare
constructor
A new instance of Bare.
- #main(args) ⇒ Object
Methods inherited from App
Constructor Details
#initialize ⇒ Bare
Returns a new instance of Bare.
8 9 10 |
# File 'lib/git-whistles/pull_request/bare.rb', line 8 def initialize super end |
Instance Method Details
#main(args) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/git-whistles/pull_request/bare.rb', line 12 def main(args) super parse_args!(args) if args.count > 0 die 'Too many arguments', :usage => true end if .from == .to die "You cannot issue a pull request to the same branch (#{options.from})." end query = {} # guess team name if .from =~ %r{^(\w+)/.*} team = $1.capitalize else team = nil end # guess title. title = .from.split('/').last.split(/[_-]/).delete_if { |word| word =~ /^\d+$/ }.join(' ').capitalize query[:"pull_request[title]"] = team ? "#{team}: #{title}" : title query.merge!((team)) query_string = query.map { |key,value| "#{CGI.escape key.to_s}=#{CGI.escape value}" }.join('&') url = "https://github.com/#{repo}/compare/#{options.to}...#{options.from}?#{query_string}" puts "Preparing a pull request for branch #{options.from}" unless launch_browser(url) log.warn "Sorry, I don't know how to launch a web browser on your system. You can open it yourself and paste this URL:\n#{url}" end end |