Peter Aronoff 965e2f50c3 brew tap: allow tapping non-GitHub repositories.
`brew tap` restricts users to GitHub and checks for private repos. I
created `brew any-tap` to support a wider variety of taps.

With very small changes (and no extra flags!), this change allows users
to use `brew tap` with GitHub as they always have or add one extra
argument and tap any repository of any type from anywhere.

    brew tap user/name              # Same as it ever was
    brew tap user/name URL          # Tap URL, whatever it happens to be

Closes Homebrew/homebrew#40326.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-06-05 21:54:12 +01:00

30 lines
886 B
Ruby

require 'cmd/tap' # for tap_args
module Homebrew
def untap
raise "Usage is `brew untap <tap-name>`" if ARGV.empty?
ARGV.each do |tapname|
user, repo = tap_args(tapname)
# We consistently downcase in tap to ensure we are not bitten by
# case-insensitive 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 = HOMEBREW_LIBRARY/"Taps/#{user}/homebrew-#{repo}"
raise "No such tap!" unless tapd.directory?
puts "Untapping #{tapname}... (#{tapd.abv})"
files = []
tapd.find_formula { |file| files << file }
tapd.rmtree
tapd.dirname.rmdir_if_possible
puts "Untapped #{files.length} formula#{plural(files.length, 'e')}"
end
end
end