diff options
| author | Mike McQuaid | 2016-12-25 21:21:58 +0000 |
|---|---|---|
| committer | GitHub | 2016-12-25 21:21:58 +0000 |
| commit | aaf70eb69656ab9f64a70c8daea4581c270766a6 (patch) | |
| tree | 3d67f83af0a1a9d299ac53f9c8e4968d724ca5ca /Library/Homebrew | |
| parent | 5b806c09ae064aaf5d61d84308009deec6cca5de (diff) | |
| parent | 8f80cc65686bd6b5eed365fd7d9f822366c01943 (diff) | |
| download | brew-aaf70eb69656ab9f64a70c8daea4581c270766a6.tar.bz2 | |
Merge pull request #1676 from MikeMcQuaid/doctor-tap-repo-bad-ruby-files
diagnostic: check for bad tap files.
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/diagnostic.rb | 23 | ||||
| -rw-r--r-- | Library/Homebrew/tap.rb | 6 |
2 files changed, 28 insertions, 1 deletions
diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 81404c625..5ac57273a 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -1087,6 +1087,29 @@ module Homebrew message 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 methods.map(&:to_s).grep(/^check_/) end diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 68b21ac60..4b59f2344 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -292,7 +292,11 @@ class Tap # path to the directory of all {Formula} files for this {Tap}. 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 # path to the directory of all {Cask} files for this {Tap}. |
