remove unnecessary tap_args

It's now handled by Tap.fetch
This commit is contained in:
Xu Cheng 2015-12-07 14:11:04 +08:00
parent 5b435db3bf
commit 2c25303949
8 changed files with 28 additions and 25 deletions

View File

@ -46,7 +46,7 @@ module Homebrew
if ARGV.named.empty?
formulae = Formula.files
else
tap = Tap.fetch(*tap_args)
tap = Tap.fetch(ARGV.named.first)
raise TapUnavailableError, tap.name unless tap.installed?
formulae = tap.formula_files
end

View File

@ -1,4 +1,4 @@
require "cmd/tap"
require "tap"
module Homebrew
def tap_info
@ -6,10 +6,12 @@ module Homebrew
taps = Tap
else
taps = ARGV.named.map do |name|
Tap.fetch(*tap_args(name))
Tap.fetch(name)
end
end
raise "Homebrew/homebrew is not allowed" if taps.any?(&:core_formula_repository?)
if ARGV.json == "v1"
print_tap_json(taps)
else

View File

@ -1,9 +1,10 @@
require "cmd/tap"
require "tap"
module Homebrew
def tap_pin
ARGV.named.each do |name|
tap = Tap.fetch(*tap_args(name))
tap = Tap.fetch(name)
raise "Homebrew/homebrew is not allowed" if tap.core_formula_repository?
tap.pin
ohai "Pinned #{tap.name}"
end

View File

@ -1,9 +1,10 @@
require "cmd/tap"
require "tap"
module Homebrew
def tap_unpin
ARGV.named.each do |name|
tap = Tap.fetch(*tap_args(name))
tap = Tap.fetch(name)
raise "Homebrew/homebrew is not allowed" if tap.core_formula_repository?
tap.unpin
ohai "Unpinned #{tap.name}"
end

View File

@ -12,8 +12,7 @@ module Homebrew
elsif ARGV.first == "--list-pinned"
puts Tap.select(&:pinned?).map(&:name)
else
user, repo = tap_args
tap = Tap.fetch(user, repo)
tap = Tap.fetch(ARGV.named[0])
begin
tap.install(:clone_target => ARGV.named[1],
:full_clone => ARGV.include?("--full"))
@ -43,12 +42,4 @@ module Homebrew
(HOMEBREW_LIBRARY/"Formula").children.each { |c| c.unlink if c.symlink? }
ignore.unlink if ignore.exist?
end
private
def tap_args(tap_name = ARGV.named.first)
tap_name =~ HOMEBREW_TAP_ARGS_REGEX
raise "Invalid tap name" unless $1 && $3
[$1, $3]
end
end

View File

@ -37,20 +37,29 @@ module Homebrew
def resolve_test_tap
tap = ARGV.value("tap")
return Tap.fetch(*tap_args(tap)) if tap
if tap
tap = Tap.fetch(tap)
return tap unless tap.core_formula_repository?
end
if ENV["UPSTREAM_BOT_PARAMS"]
bot_argv = ENV["UPSTREAM_BOT_PARAMS"].split " "
bot_argv.extend HomebrewArgvExtension
tap = bot_argv.value("tap")
return Tap.fetch(*tap_args(tap)) if tap
if tap
tap = Tap.fetch(tap)
return tap unless tap.core_formula_repository?
end
end
if git_url = ENV["UPSTREAM_GIT_URL"] || ENV["GIT_URL"]
# Also can get tap from Jenkins GIT_URL.
url_path = git_url.sub(%r{^https?://github\.com/}, "").chomp("/")
HOMEBREW_TAP_ARGS_REGEX =~ url_path
return Tap.fetch($1, $3) if $1 && $3 && $3 != "homebrew"
begin
tap = Tap.fetch(tap)
return tap unless tap.core_formula_repository?
rescue
end
end
# return nil means we are testing core repo.

View File

@ -1,11 +1,12 @@
require "cmd/tap" # for tap_args
require "tap"
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))
tap = Tap.fetch(tapname)
raise "Homebrew/homebrew is not allowed" if tap.core_formula_repository?
tap.uninstall
end
end

View File

@ -1,5 +1,3 @@
# match expressions when taps are given as ARGS, e.g. someuser/sometap
HOMEBREW_TAP_ARGS_REGEX = %r{^([\w-]+)/(homebrew-)?([\w-]+)$}
# match taps' formulae, e.g. someuser/sometap/someformula
HOMEBREW_TAP_FORMULA_REGEX = %r{^([\w-]+)/([\w-]+)/([\w+-.]+)$}
# match core's formulae, e.g. homebrew/homebrew/someformula