Merge pull request #4002 from reitermarkus/tap-path-loader

Use `TapPathLoader` in more cases.
This commit is contained in:
Markus Reiter 2018-03-29 22:19:53 +02:00 committed by GitHub
commit cc2d9d926e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 9 deletions

View File

@ -97,14 +97,14 @@ module Hbc
class FromTapPathLoader < FromPathLoader
def self.can_load?(ref)
ref.to_s.match?(HOMEBREW_TAP_PATH_REGEX) && super
super && !Tap.from_path(ref).nil?
end
attr_reader :tap
def initialize(tap_path)
@tap = Tap.from_path(tap_path)
super tap_path
def initialize(path)
@tap = Tap.from_path(path)
super(path)
end
private

View File

@ -181,8 +181,7 @@ class TapFormulaAmbiguityError < RuntimeError
@name = name
@paths = paths
@formulae = paths.map do |path|
match = path.to_s.match(HOMEBREW_TAP_PATH_REGEX)
"#{Tap.fetch(match[:user], match[:repo])}/#{path.basename(".rb")}"
"#{Tap.from_path(path).name}/#{path.basename(".rb")}"
end
super <<~EOS

View File

@ -179,8 +179,8 @@ class Formula
@tap = if path == Formulary.core_path(name)
CoreTap.instance
elsif match = path.to_s.match(HOMEBREW_TAP_PATH_REGEX)
Tap.fetch(match[:user], match[:repo])
else
Tap.from_path(path)
end
@full_name = full_name_with_optional_tap(name)

View File

@ -39,7 +39,7 @@ class Tap
end
def self.from_path(path)
match = path.to_s.match(HOMEBREW_TAP_PATH_REGEX)
match = File.expand_path(path).match(HOMEBREW_TAP_PATH_REGEX)
raise "Invalid tap path '#{path}'" unless match
fetch(match[:user], match[:repo])
rescue