untap: Handle multiple arguments

Closes Homebrew/homebrew#36436.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
chdiza 2015-02-01 12:11:54 -05:00 committed by Mike McQuaid
parent 8a707ebb2b
commit 5e854164a7
2 changed files with 19 additions and 17 deletions

View File

@ -108,8 +108,8 @@ module Homebrew
end end
end end
def tap_args def tap_args(tap_name=ARGV.first)
ARGV.first =~ HOMEBREW_TAP_ARGS_REGEX tap_name =~ HOMEBREW_TAP_ARGS_REGEX
raise "Invalid tap name" unless $1 && $3 raise "Invalid tap name" unless $1 && $3
[$1, $3] [$1, $3]
end end

View File

@ -4,25 +4,27 @@ module Homebrew
def untap def untap
raise "Usage is `brew untap <tap-name>`" if ARGV.empty? raise "Usage is `brew untap <tap-name>`" if ARGV.empty?
user, repo = tap_args ARGV.each do |tapname|
user, repo = tap_args(tapname)
# we consistently downcase in tap to ensure we are not bitten by case-insensive # 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 issues. Which is the default on mac. The problem being the
# filesystem cares, but our regexps don't. So unless we resolve *every* path # filesystem cares, but our regexps don't. So unless we resolve *every* path
# we will get bitten. # we will get bitten.
user.downcase! user.downcase!
repo.downcase! repo.downcase!
tapd = HOMEBREW_LIBRARY/"Taps/#{user}/homebrew-#{repo}" tapd = HOMEBREW_LIBRARY/"Taps/#{user}/homebrew-#{repo}"
raise "No such tap!" unless tapd.directory? raise "No such tap!" unless tapd.directory?
files = [] files = []
tapd.find_formula { |file| files << file } tapd.find_formula { |file| files << file }
unlink_tap_formula(files) unlink_tap_formula(files)
tapd.rmtree tapd.rmtree
tapd.dirname.rmdir_if_possible tapd.dirname.rmdir_if_possible
puts "Untapped #{files.length} formula#{plural(files.length, 'e')}" puts "Untapped #{files.length} formula#{plural(files.length, 'e')}"
end
end end
def unlink_tap_formula paths def unlink_tap_formula paths