Xu Cheng 3b520cf195 cache taps
There are plenty of IO operations inside Tap object, and it will be more
when implementing formula alias reverse look up(e.g. list all of alias
names for a formula). So let's cache them.

Some benchmark:

$ time brew info $(brew ruby -e 'puts Formula.tap_names') > /dev/null
Before: 6.40s user 2.42s system 96% cpu 9.134 total
After: 4.75s user 0.77s system 97% cpu 5.637 total

Closes Homebrew/homebrew#44377.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-09-30 16:25:30 +08:00

24 lines
627 B
Ruby

require "cmd/tap" # for tap_args
require "descriptions"
module Homebrew
def untap
raise "Usage is `brew untap <tap-name>`" if ARGV.empty?
ARGV.named.each do |tapname|
tap = Tap.fetch(*tap_args(tapname))
raise TapUnavailableError, tap.name unless tap.installed?
puts "Untapping #{tap}... (#{tap.path.abv})"
tap.unpin if tap.pinned?
formula_count = tap.formula_files.size
Descriptions.uncache_formulae(tap.formula_names)
tap.path.rmtree
tap.path.dirname.rmdir_if_possible
puts "Untapped #{formula_count} formula#{plural(formula_count, "e")}"
end
end
end