diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb index 1f4ec19b5988..e4a787455136 100644 --- a/Library/Homebrew/cmd/tap.rb +++ b/Library/Homebrew/cmd/tap.rb @@ -4,24 +4,21 @@ def tap if ARGV.empty? tapd = HOMEBREW_LIBRARY/"Taps" tapd.children.each do |tap| - puts tap.basename.sub('-', '/') if (tap/'.git').directory? + next unless (tap/'.git').directory? + puts tap.basename.to_s =~ /^direct_/ ? tap.basename.sub(/^direct_/,'') : tap.basename.sub('-','/') end if tapd.directory? else install_tap(*tap_args) end end - def install_tap user, repo + def install_tap clone_url, tapd_name raise "brew install git" unless which 'git' - # we special case homebrew so users don't have to shift in a terminal - repouser = if user == "homebrew" then "Homebrew" else user end - user = "homebrew" if user == "Homebrew" - # we downcase to avoid case-insensitive filesystem issues - tapd = HOMEBREW_LIBRARY/"Taps/#{user.downcase}-#{repo.downcase}" + tapd = HOMEBREW_LIBRARY/"Taps/#{tapd_name.downcase}" raise "Already tapped!" if tapd.directory? - abort unless system "git clone https://github.com/#{repouser}/homebrew-#{repo} #{tapd}" + abort unless system "git clone #{clone_url} #{tapd}" files = [] tapd.find_formula{ |file| files << tapd.basename.join(file) } @@ -60,10 +57,24 @@ def link_tap_formula formulae private - def tap_args - ARGV.first =~ %r{^(\S+)/(homebrew-)?(\w+)$} - raise "Invalid usage" unless $1 and $3 - [$1, $3] + def tap_args return_nil = false + case ARGV.first + when %r{^(https?|git)://\S+/(\S+?)(\.git)?$} + [ARGV.first, "direct_#{File.basename($2)}"] + when %r{^\S+@\S+:(\S+?)(\.git)?$} + [ARGV.first, "direct_#{File.basename($1)}"] + when %r{^(\S+)/(homebrew-)?(\w+)$} + user, repo = $1, $3 + + # we special case homebrew so users don't have to shift in a terminal + repouser = if user == "homebrew" then "Homebrew" else user end + user = "homebrew" if user == "Homebrew" + + ["https://github.com/#{repouser}/homebrew-#{repo}", "#{user}-#{repo}"] + else + return nil if return_nil + raise "Invalid usage" + end end end diff --git a/Library/Homebrew/cmd/untap.rb b/Library/Homebrew/cmd/untap.rb index 148e96448d12..3e4b0b1f7437 100644 --- a/Library/Homebrew/cmd/untap.rb +++ b/Library/Homebrew/cmd/untap.rb @@ -2,21 +2,22 @@ module Homebrew extend self def untap - user, repo = tap_args + clone_url, tapd_name = tap_args(true) + + tapd_name = "direct_#{ARGV.first}" unless tapd_name # we consistently downcase in tap to ensure we are not bitten by case-insensive # filesystem issues. Which is the default on mac. The problem being the # filesystem cares, but our regexps don't. So unless we resolve *every* path # we will get bitten. - user.downcase! - repo.downcase! + tapd_name.downcase! - tapd = HOMEBREW_LIBRARY/"Taps/#{user}-#{repo}" + tapd = HOMEBREW_LIBRARY/"Taps/#{tapd_name}" raise "No such tap!" unless tapd.directory? files = [] - tapd.find_formula{ |file| files << Pathname.new("#{user}-#{repo}").join(file) } + tapd.find_formula{ |file| files << Pathname.new(tapd_name).join(file) } untapped = unlink_tap_formula(files) rm_rf tapd puts "Untapped #{untapped} formula"