load tap formula through direct search
This commit is contained in:
parent
3a3a49bd93
commit
811c4c5add
@ -65,6 +65,25 @@ class TapFormulaUnavailableError < FormulaUnavailableError
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class TapFormulaAmbiguityError < RuntimeError
|
||||||
|
attr_reader :name, :paths, :formulae
|
||||||
|
|
||||||
|
def initialize name, paths
|
||||||
|
@name = name
|
||||||
|
@paths = paths
|
||||||
|
@formulae = paths.map do |path|
|
||||||
|
path.to_s =~ HOMEBREW_TAP_PATH_REGEX
|
||||||
|
"#{$1}/#{$2.sub("homebrew-", "")}/#{path.basename(".rb")}"
|
||||||
|
end
|
||||||
|
|
||||||
|
super <<-EOS.undent
|
||||||
|
Formulae found in multiple taps: #{formulae.map { |f| "\n * #{f}" }.join}
|
||||||
|
|
||||||
|
Please use the fully-qualified name e.g. #{formulae.first} to refer the formula.
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class OperationInProgressError < RuntimeError
|
class OperationInProgressError < RuntimeError
|
||||||
def initialize name
|
def initialize name
|
||||||
message = <<-EOS.undent
|
message = <<-EOS.undent
|
||||||
|
|||||||
@ -232,6 +232,13 @@ class Formulary
|
|||||||
return AliasLoader.new(possible_alias)
|
return AliasLoader.new(possible_alias)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
possible_tap_formulae = tap_paths(ref)
|
||||||
|
if possible_tap_formulae.size > 1
|
||||||
|
raise TapFormulaAmbiguityError.new(ref, possible_tap_formulae)
|
||||||
|
elsif possible_tap_formulae.size == 1
|
||||||
|
return FormulaLoader.new(ref, possible_tap_formulae.first)
|
||||||
|
end
|
||||||
|
|
||||||
possible_cached_formula = Pathname.new("#{HOMEBREW_CACHE_FORMULA}/#{ref}.rb")
|
possible_cached_formula = Pathname.new("#{HOMEBREW_CACHE_FORMULA}/#{ref}.rb")
|
||||||
if possible_cached_formula.file?
|
if possible_cached_formula.file?
|
||||||
return FormulaLoader.new(ref, possible_cached_formula)
|
return FormulaLoader.new(ref, possible_cached_formula)
|
||||||
@ -243,4 +250,12 @@ class Formulary
|
|||||||
def self.core_path(name)
|
def self.core_path(name)
|
||||||
Pathname.new("#{HOMEBREW_LIBRARY}/Formula/#{name.downcase}.rb")
|
Pathname.new("#{HOMEBREW_LIBRARY}/Formula/#{name.downcase}.rb")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.tap_paths(name)
|
||||||
|
name = name.downcase
|
||||||
|
Dir["#{HOMEBREW_LIBRARY}/Taps/*/*/"].map do |tap|
|
||||||
|
Pathname.glob(["#{tap}#{name}.rb", "#{tap}Formula/#{name}.rb",
|
||||||
|
"#{tap}HomebrewFormula/#{name}.rb"])
|
||||||
|
end.flatten.select(&:file?)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user