diagnostic: check for bad tap files.

Check for Ruby files in taps that are outside of the detected `Formula`
directory for a tap but inside one of the other potential directories.

This usually indicates a formula has been added in the wrong directory
in a tap and is used to fail CI in this case.
This commit is contained in:
Mike McQuaid 2016-12-13 01:53:05 +00:00
parent 666463ca2b
commit 8f80cc6568
2 changed files with 28 additions and 1 deletions

View File

@ -1075,6 +1075,29 @@ module Homebrew
message message
end end
def check_for_tap_ruby_files_locations
bad_tap_files = {}
Tap.each do |tap|
unused_formula_dirs = tap.potential_formula_dirs - [tap.formula_dir]
unused_formula_dirs.each do |dir|
next unless dir.exist?
dir.children.each do |path|
next unless path.extname == ".rb"
bad_tap_files[tap] ||= []
bad_tap_files[tap] << path
end
end
end
return if bad_tap_files.empty?
bad_tap_files.keys.map do |tap|
<<-EOS.undent
Found Ruby file outside #{tap} tap formula directory
(#{tap.formula_dir}):
#{bad_tap_files[tap].join("\n ")}
EOS
end.join("\n")
end
def all def all
methods.map(&:to_s).grep(/^check_/) methods.map(&:to_s).grep(/^check_/)
end end

View File

@ -292,7 +292,11 @@ class Tap
# path to the directory of all {Formula} files for this {Tap}. # path to the directory of all {Formula} files for this {Tap}.
def formula_dir def formula_dir
@formula_dir ||= [path/"Formula", path/"HomebrewFormula", path].detect(&:directory?) @formula_dir ||= potential_formula_dirs.detect(&:directory?)
end
def potential_formula_dirs
@potential_formula_dirs ||= [path/"Formula", path/"HomebrewFormula", path].freeze
end end
# path to the directory of all {Cask} files for this {Tap}. # path to the directory of all {Cask} files for this {Tap}.