8000 BottleLoader: Use the formula stored in the bottle by sjackman · Pull Request #3176 · Homebrew/brew · GitHub
[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BottleLoader: Use the formula stored in the bottle #3176

Merged
merged 6 commits into from
Sep 29, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
BottleLoader: Use the formula stored in the bottle
  • Loading branch information
sjackman committed Sep 28, 2017
commit 3ed832d4f0465aa9d938d3f4867ad12aaf394710
10 changes: 5 additions & 5 deletions Library/Homebrew/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -555,12 +555,12 @@ def initialize(resource)
# 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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about outputting the bottle file and expected formula path within it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

#{bottle_path}
#{formula_path}
EOS
end
end
10 changes: 3 additions & 7 deletions Library/Homebrew/formulary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,10 @@ def initialize(bottle_name)
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
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/test/exceptions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ class Baz < Formula; end
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
0