BottleLoader: Use the formula stored in the bottle
This commit is contained in:
parent
9642ec769e
commit
3ed832d4f0
@ -555,12 +555,12 @@ end
|
||||
# raised when a single patch file is not found and apply hasn't been specified
|
||||
class MissingApplyError < RuntimeError; end
|
||||
|
||||
class BottleVersionMismatchError < RuntimeError
|
||||
def initialize(bottle_file, bottle_version, formula, formula_version)
|
||||
class BottleFormulaUnavailableError < RuntimeError
|
||||
def initialize(bottle_path, formula_path)
|
||||
super <<-EOS.undent
|
||||
Bottle version mismatch
|
||||
Bottle: #{bottle_file} (#{bottle_version})
|
||||
Formula: #{formula.full_name} (#{formula_version})
|
||||
This bottle does not contain the formula file:
|
||||
#{bottle_path}
|
||||
#{formula_path}
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
@ -122,14 +122,10 @@ module Formulary
|
||||
super name, Formulary.path(full_name)
|
||||
end
|
||||
|
||||
def get_formula(spec, alias_path: nil)
|
||||
formula = super
|
||||
def get_formula(spec, **)
|
||||
contents = Utils::Bottles.formula_contents @bottle_filename, name: name
|
||||
formula = Formulary.from_contents name, @bottle_filename, contents, spec
|
||||
formula.local_bottle_path = @bottle_filename
|
||||
formula_version = formula.pkg_version
|
||||
bottle_version = Utils::Bottles.resolve_version(@bottle_filename)
|
||||
unless formula_version == bottle_version
|
||||
raise BottleVersionMismatchError.new(@bottle_filename, bottle_version, formula, formula_version)
|
||||
end
|
||||
formula
|
||||
end
|
||||
end
|
||||
|
||||
@ -181,8 +181,8 @@ describe DuplicateResourceError do
|
||||
its(:to_s) { is_expected.to eq("Resource <resource foo> is defined more than once") }
|
||||
end
|
||||
|
||||
describe BottleVersionMismatchError do
|
||||
subject { described_class.new("/foo.bottle.tar.gz", "1.0", formula, "1.1") }
|
||||
describe BottleFormulaUnavailableError do
|
||||
subject { described_class.new("/foo.bottle.tar.gz", "foo/1.0/.brew/foo.rb") }
|
||||
let(:formula) { double(Formula, full_name: "foo") }
|
||||
its(:to_s) { is_expected.to match(/Bottle version mismatch/) }
|
||||
its(:to_s) { is_expected.to match(/This bottle does not contain the formula file/) }
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user