Merge pull request #20487 from Homebrew/formulary-forbid-cache
formulary: do not allow using the cache when forbidding paths
This commit is contained in:
commit
0cadd6d0c1
@ -620,8 +620,8 @@ module Formulary
|
||||
path_realpath = path.realpath.to_s
|
||||
path_string = path.to_s
|
||||
if (path_realpath.end_with?(".rb") || path_string.end_with?(".rb")) &&
|
||||
!path_realpath.start_with?("#{HOMEBREW_CELLAR}/", "#{HOMEBREW_LIBRARY}/Taps/", "#{HOMEBREW_CACHE}/") &&
|
||||
!path_string.start_with?("#{HOMEBREW_CELLAR}/", "#{HOMEBREW_LIBRARY}/Taps/", "#{HOMEBREW_CACHE}/")
|
||||
!path_realpath.start_with?("#{HOMEBREW_CELLAR}/", "#{HOMEBREW_LIBRARY}/Taps/") &&
|
||||
!path_string.start_with?("#{HOMEBREW_CELLAR}/", "#{HOMEBREW_LIBRARY}/Taps/")
|
||||
if path_string.include?("./") || path_string.end_with?(".rb") || path_string.count("/") != 2
|
||||
raise <<~WARNING
|
||||
Homebrew requires formulae to be in a tap, rejecting:
|
||||
|
||||
@ -141,19 +141,26 @@ RSpec.describe Formulary do
|
||||
end.to raise_error(FormulaUnavailableError)
|
||||
end
|
||||
|
||||
it "allows cache paths even when paths are disabled" do
|
||||
ENV["HOMEBREW_FORBID_PACKAGES_FROM_PATHS"] = "1"
|
||||
cache_dir = HOMEBREW_CACHE/"test_formula_cache"
|
||||
context "when given a cache path" do
|
||||
let(:cache_dir) { HOMEBREW_CACHE/"test_formula_cache" }
|
||||
let(:cache_formula_path) { cache_dir/formula_path.basename }
|
||||
|
||||
before do
|
||||
cache_dir.mkpath
|
||||
cache_formula_path = cache_dir/formula_path.basename
|
||||
FileUtils.cp formula_path, cache_formula_path
|
||||
begin
|
||||
formula = described_class.factory(cache_formula_path)
|
||||
expect(formula).to be_a(Formula)
|
||||
ensure
|
||||
end
|
||||
|
||||
after do
|
||||
cache_formula_path.unlink if cache_formula_path.exist?
|
||||
cache_dir.rmdir if cache_dir.exist?
|
||||
end
|
||||
|
||||
it "disallows cache paths when paths are explicitly disabled" do
|
||||
ENV["HOMEBREW_FORBID_PACKAGES_FROM_PATHS"] = "1"
|
||||
expect do
|
||||
described_class.factory(cache_formula_path)
|
||||
end.to raise_error(/requires formulae to be in a tap/)
|
||||
end
|
||||
end
|
||||
|
||||
context "when given a bottle" do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user