aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShaun Jackman2017-09-19 12:22:32 -0700
committerShaun Jackman2017-09-28 12:29:23 -0700
commit3ed832d4f0465aa9d938d3f4867ad12aaf394710 (patch)
tree2cc3303acfdfbc1ed4bc1f9ee76a625fef42e34d
parent9642ec769e6b187c375964e4206e5ac4014d37fa (diff)
downloadbrew-3ed832d4f0465aa9d938d3f4867ad12aaf394710.tar.bz2
BottleLoader: Use the formula stored in the bottle
-rw-r--r--Library/Homebrew/exceptions.rb10
-rw-r--r--Library/Homebrew/formulary.rb10
-rw-r--r--Library/Homebrew/test/exceptions_spec.rb6
3 files changed, 11 insertions, 15 deletions
diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb
index 5418f9331..22a7fe023 100644
--- a/Library/Homebrew/exceptions.rb
+++ b/Library/Homebrew/exceptions.rb
@@ -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
diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb
index dd67b4f24..c8ab8a922 100644
--- a/Library/Homebrew/formulary.rb
+++ b/Library/Homebrew/formulary.rb
@@ -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
diff --git a/Library/Homebrew/test/exceptions_spec.rb b/Library/Homebrew/test/exceptions_spec.rb
index 33547ea32..0a8313355 100644
--- a/Library/Homebrew/test/exceptions_spec.rb
+++ b/Library/Homebrew/test/exceptions_spec.rb
@@ -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