audit: do not allow aliases and renames in formula conflicts
This commit is contained in:
parent
84e3e0a6b8
commit
1ddb6ef584
@ -318,9 +318,24 @@ module Homebrew
|
||||
conflicting_formula = Formulary.factory(c.name)
|
||||
problem "Formula should not conflict with itself" if formula == conflicting_formula
|
||||
|
||||
# Use Formula instead of FormulaConflict to be able correctly handle renamed formulae and aliases
|
||||
reverse_conflicts = conflicting_formula.conflicts.map { |rc| Formulary.factory(rc.name) }
|
||||
if reverse_conflicts.exclude? formula
|
||||
next unless @core_tap
|
||||
|
||||
if CoreTap.instance.formula_renames.key?(c.name) || Formula.aliases.include?(c.name)
|
||||
problem "Formula conflict should be declared using " \
|
||||
"canonical name (#{conflicting_formula.name}) instead of #{c.name}"
|
||||
end
|
||||
|
||||
rev_conflict_found = false
|
||||
conflicting_formula.conflicts.each do |rc|
|
||||
rc_formula = Formulary.factory(rc.name)
|
||||
if CoreTap.instance.formula_renames.key?(rc.name) || Formula.aliases.include?(rc.name)
|
||||
problem "Formula #{conflicting_formula.name} conflict should be declared using " \
|
||||
"canonical name (#{rc_formula.name}) instead of #{rc.name}"
|
||||
end
|
||||
|
||||
rev_conflict_found ||= rc_formula == formula
|
||||
end
|
||||
unless rev_conflict_found
|
||||
problem "Formula #{conflicting_formula.name} should also have a conflict declared with #{formula.name}"
|
||||
end
|
||||
rescue TapFormulaUnavailableError
|
||||
|
||||
@ -1142,7 +1142,7 @@ module Homebrew
|
||||
|
||||
describe "#audit_conflicts" do
|
||||
specify "it warns when conflicting with non-existing formula" do
|
||||
fa = formula_auditor "foo", <<~RUBY
|
||||
fa = formula_auditor "foo", <<~RUBY, core_tap: true
|
||||
class Foo < Formula
|
||||
url "https://brew.sh/foo-1.0.tgz"
|
||||
|
||||
@ -1157,7 +1157,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
specify "it warns when conflicting with itself" do
|
||||
fa = formula_auditor "foo", <<~RUBY
|
||||
fa = formula_auditor "foo", <<~RUBY, core_tap: true
|
||||
class Foo < Formula
|
||||
url "https://brew.sh/foo-1.0.tgz"
|
||||
|
||||
@ -1172,13 +1172,13 @@ module Homebrew
|
||||
end
|
||||
|
||||
specify "it warns when another formula does not have a symmetric conflict" do
|
||||
formula_auditor "bar", <<~RUBY
|
||||
formula_auditor "bar", <<~RUBY, core_tap: true
|
||||
class Bar < Formula
|
||||
url "https://brew.sh/foo-1.0.tgz"
|
||||
end
|
||||
RUBY
|
||||
|
||||
fa = formula_auditor "foo", <<~RUBY
|
||||
fa = formula_auditor "foo", <<~RUBY, core_tap: true
|
||||
class Foo < Formula
|
||||
url "https://brew.sh/foo-1.0.tgz"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user