Merge pull request #3510 from MikeMcQuaid/remove-bottle-hooks
hooks/bottles: remove bottle hooks.
This commit is contained in:
commit
b41eb9d306
@ -9,7 +9,6 @@ require "cleaner"
|
|||||||
require "formula_cellar_checks"
|
require "formula_cellar_checks"
|
||||||
require "install_renamed"
|
require "install_renamed"
|
||||||
require "cmd/postinstall"
|
require "cmd/postinstall"
|
||||||
require "hooks/bottles"
|
|
||||||
require "debrew"
|
require "debrew"
|
||||||
require "sandbox"
|
require "sandbox"
|
||||||
require "emoji"
|
require "emoji"
|
||||||
@ -81,8 +80,6 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pour_bottle?(install_bottle_options = { warn: false })
|
def pour_bottle?(install_bottle_options = { warn: false })
|
||||||
return true if Homebrew::Hooks::Bottles.formula_has_bottle?(formula)
|
|
||||||
|
|
||||||
return false if @pour_failed
|
return false if @pour_failed
|
||||||
|
|
||||||
return false if !formula.bottled? && !formula.local_bottle_path
|
return false if !formula.bottled? && !formula.local_bottle_path
|
||||||
@ -858,10 +855,6 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pour
|
def pour
|
||||||
if Homebrew::Hooks::Bottles.formula_has_bottle?(formula)
|
|
||||||
return if Homebrew::Hooks::Bottles.pour_formula_bottle(formula)
|
|
||||||
end
|
|
||||||
|
|
||||||
if (bottle_path = formula.local_bottle_path)
|
if (bottle_path = formula.local_bottle_path)
|
||||||
downloader = LocalBottleDownloadStrategy.new(bottle_path)
|
downloader = LocalBottleDownloadStrategy.new(bottle_path)
|
||||||
else
|
else
|
||||||
|
|||||||
@ -1,35 +0,0 @@
|
|||||||
# Boxen (and perhaps others) want to override our bottling infrastructure so
|
|
||||||
# they can avoid declaring checksums in formulae files.
|
|
||||||
# Instead of periodically breaking their monkeypatches let's add some hooks that
|
|
||||||
# we can query to allow their own behaviour.
|
|
||||||
|
|
||||||
# PLEASE DO NOT EVER RENAME THIS CLASS OR ADD/REMOVE METHOD ARGUMENTS!
|
|
||||||
module Homebrew
|
|
||||||
module Hooks
|
|
||||||
module Bottles
|
|
||||||
def self.setup_formula_has_bottle(&block)
|
|
||||||
@has_bottle = block
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.setup_pour_formula_bottle(&block)
|
|
||||||
@pour_bottle = block
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.formula_has_bottle?(formula)
|
|
||||||
return false unless @has_bottle
|
|
||||||
@has_bottle.call formula
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.pour_formula_bottle(formula)
|
|
||||||
return false unless @pour_bottle
|
|
||||||
@pour_bottle.call formula
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.reset_hooks
|
|
||||||
@has_bottle = @pour_bottle = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -1,51 +0,0 @@
|
|||||||
require "formula_installer"
|
|
||||||
require "hooks/bottles"
|
|
||||||
|
|
||||||
describe Homebrew::Hooks::Bottles do
|
|
||||||
alias_matcher :pour_bottle, :be_pour_bottle
|
|
||||||
|
|
||||||
subject { FormulaInstaller.new formula }
|
|
||||||
|
|
||||||
let(:formula) do
|
|
||||||
double(
|
|
||||||
bottled?: false,
|
|
||||||
local_bottle_path: nil,
|
|
||||||
bottle_disabled?: false,
|
|
||||||
some_random_method: true,
|
|
||||||
keg_only?: false,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
after(:each) do
|
|
||||||
described_class.reset_hooks
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#setup_formula_has_bottle" do
|
|
||||||
context "given a block which evaluates to true" do
|
|
||||||
before(:each) do
|
|
||||||
described_class.setup_formula_has_bottle(&:some_random_method)
|
|
||||||
end
|
|
||||||
|
|
||||||
it { is_expected.to pour_bottle }
|
|
||||||
end
|
|
||||||
|
|
||||||
context "given a block which evaluates to false" do
|
|
||||||
before(:each) do
|
|
||||||
described_class.setup_formula_has_bottle { |f| !f.some_random_method }
|
|
||||||
end
|
|
||||||
|
|
||||||
it { is_expected.not_to pour_bottle }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#setup_pour_formula_bottle" do
|
|
||||||
before(:each) do
|
|
||||||
described_class.setup_formula_has_bottle { true }
|
|
||||||
described_class.setup_pour_formula_bottle(&:some_random_method)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "does not raise an error" do
|
|
||||||
expect { subject.pour }.not_to raise_error
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Loading…
x
Reference in New Issue
Block a user