From 2c25303949a9fa091868cbdd42fd4ff4877869fc Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Mon, 7 Dec 2015 14:11:04 +0800 Subject: [PATCH] remove unnecessary tap_args It's now handled by Tap.fetch --- Library/Homebrew/cmd/readall.rb | 2 +- Library/Homebrew/cmd/tap-info.rb | 6 ++++-- Library/Homebrew/cmd/tap-pin.rb | 5 +++-- Library/Homebrew/cmd/tap-unpin.rb | 5 +++-- Library/Homebrew/cmd/tap.rb | 11 +---------- Library/Homebrew/cmd/test-bot.rb | 17 +++++++++++++---- Library/Homebrew/cmd/untap.rb | 5 +++-- Library/Homebrew/tap_constants.rb | 2 -- 8 files changed, 28 insertions(+), 25 deletions(-) diff --git a/Library/Homebrew/cmd/readall.rb b/Library/Homebrew/cmd/readall.rb index 5e87fcbdb5..4d575195e1 100644 --- a/Library/Homebrew/cmd/readall.rb +++ b/Library/Homebrew/cmd/readall.rb @@ -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 diff --git a/Library/Homebrew/cmd/tap-info.rb b/Library/Homebrew/cmd/tap-info.rb index 80f1d4e38d..8139b49433 100644 --- a/Library/Homebrew/cmd/tap-info.rb +++ b/Library/Homebrew/cmd/tap-info.rb @@ -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 diff --git a/Library/Homebrew/cmd/tap-pin.rb b/Library/Homebrew/cmd/tap-pin.rb index 80f1f762ad..e906c700d4 100644 --- a/Library/Homebrew/cmd/tap-pin.rb +++ b/Library/Homebrew/cmd/tap-pin.rb @@ -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 diff --git a/Library/Homebrew/cmd/tap-unpin.rb b/Library/Homebrew/cmd/tap-unpin.rb index 641b7c9453..e36a68ed03 100644 --- a/Library/Homebrew/cmd/tap-unpin.rb +++ b/Library/Homebrew/cmd/tap-unpin.rb @@ -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 diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb index 701931f1e4..08b9e8327b 100644 --- a/Library/Homebrew/cmd/tap.rb +++ b/Library/Homebrew/cmd/tap.rb @@ -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 diff --git a/Library/Homebrew/cmd/test-bot.rb b/Library/Homebrew/cmd/test-bot.rb index 498b8444de..2c5ef7f7f2 100644 --- a/Library/Homebrew/cmd/test-bot.rb +++ b/Library/Homebrew/cmd/test-bot.rb @@ -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. diff --git a/Library/Homebrew/cmd/untap.rb b/Library/Homebrew/cmd/untap.rb index 2d08ae8c7a..8f14258f31 100644 --- a/Library/Homebrew/cmd/untap.rb +++ b/Library/Homebrew/cmd/untap.rb @@ -1,11 +1,12 @@ -require "cmd/tap" # for tap_args +require "tap" module Homebrew def untap raise "Usage is `brew untap `" 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 diff --git a/Library/Homebrew/tap_constants.rb b/Library/Homebrew/tap_constants.rb index 6502b61d84..ce470bd4b3 100644 --- a/Library/Homebrew/tap_constants.rb +++ b/Library/Homebrew/tap_constants.rb @@ -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