missing_deps: extract formula instance method
This commit is contained in:
parent
99a7fb8cb4
commit
0cd983487c
@ -8,27 +8,13 @@ require "utils/shell"
|
||||
module Homebrew
|
||||
module Diagnostic
|
||||
def self.missing_deps(ff, hide = nil)
|
||||
hide ||= []
|
||||
|
||||
missing = {}
|
||||
ff.each do |f|
|
||||
missing_deps = f.recursive_dependencies do |dependent, dep|
|
||||
if dep.optional? || dep.recommended?
|
||||
tab = Tab.for_formula(dependent)
|
||||
Dependency.prune unless tab.with?(dep)
|
||||
elsif dep.build?
|
||||
Dependency.prune
|
||||
end
|
||||
end
|
||||
missing_dependencies = f.missing_dependencies(hide: hide)
|
||||
|
||||
missing_deps.map!(&:to_formula)
|
||||
missing_deps.reject! do |d|
|
||||
!hide.include?(d.name) && d.installed_prefixes.any?
|
||||
end
|
||||
|
||||
unless missing_deps.empty?
|
||||
yield f.full_name, missing_deps if block_given?
|
||||
missing[f.full_name] = missing_deps
|
||||
unless missing_dependencies.empty?
|
||||
yield f.full_name, missing_dependencies if block_given?
|
||||
missing[f.full_name] = missing_dependencies
|
||||
end
|
||||
end
|
||||
missing
|
||||
|
||||
@ -1466,6 +1466,26 @@ class Formula
|
||||
recursive_dependencies.reject(&:build?)
|
||||
end
|
||||
|
||||
# Returns a list of formulae depended on by this formula that aren't
|
||||
# installed
|
||||
def missing_dependencies(hide: nil)
|
||||
hide ||= []
|
||||
missing_dependencies = recursive_dependencies do |dependent, dep|
|
||||
if dep.optional? || dep.recommended?
|
||||
tab = Tab.for_formula(dependent)
|
||||
Dependency.prune unless tab.with?(dep)
|
||||
elsif dep.build?
|
||||
Dependency.prune
|
||||
end
|
||||
end
|
||||
|
||||
missing_dependencies.map!(&:to_formula)
|
||||
missing_dependencies.select! do |d|
|
||||
hide.include?(d.name) || d.installed_prefixes.empty?
|
||||
end
|
||||
missing_dependencies
|
||||
end
|
||||
|
||||
# @private
|
||||
def to_hash
|
||||
hsh = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user