diagnostics: add formula/cask dup check
Duplicate names across taps are a real pain to deal with, so let's warn the user.
This commit is contained in:
parent
2bd665f65a
commit
46b49ff34d
@ -1040,6 +1040,40 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def non_core_taps
|
||||||
|
@non_core_taps ||= Tap.installed.reject(&:core_tap?).reject(&:core_cask_tap?)
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_for_duplicate_formulae
|
||||||
|
core_formula_names = CoreTap.instance.formula_names
|
||||||
|
shadowed_formula_full_names = non_core_taps.flat_map do |tap|
|
||||||
|
tap_formula_names = tap.formula_names.map { |s| s.delete_prefix("#{tap.name}/") }
|
||||||
|
(core_formula_names & tap_formula_names).map { |f| "#{tap.name}/#{f}" }
|
||||||
|
end.compact
|
||||||
|
return if shadowed_formula_full_names.empty?
|
||||||
|
|
||||||
|
<<~EOS
|
||||||
|
The following formulae have the same name as core formulae:
|
||||||
|
#{shadowed_formula_full_names.join("\n ")}
|
||||||
|
You will need to use their full names throughout Homebrew.
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_for_duplicate_casks
|
||||||
|
core_cask_names = CoreCaskTap.instance.cask_tokens
|
||||||
|
shadowed_cask_full_names = non_core_taps.flat_map do |tap|
|
||||||
|
tap_cask_names = tap.cask_tokens.map { |s| s.delete_prefix("#{tap.name}/") }
|
||||||
|
(core_cask_names & tap_cask_names).map { |f| "#{tap.name}/#{f}" }
|
||||||
|
end.compact
|
||||||
|
return if shadowed_cask_full_names.empty?
|
||||||
|
|
||||||
|
<<~EOS
|
||||||
|
The following casks have the same name as core casks:
|
||||||
|
#{shadowed_cask_full_names.join("\n ")}
|
||||||
|
You will need to use their full names throughout Homebrew.
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
def all
|
def all
|
||||||
methods.map(&:to_s).grep(/^check_/).sort
|
methods.map(&:to_s).grep(/^check_/).sort
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user