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 Homebrew
|
||||||
module Diagnostic
|
module Diagnostic
|
||||||
def self.missing_deps(ff, hide = nil)
|
def self.missing_deps(ff, hide = nil)
|
||||||
hide ||= []
|
|
||||||
|
|
||||||
missing = {}
|
missing = {}
|
||||||
ff.each do |f|
|
ff.each do |f|
|
||||||
missing_deps = f.recursive_dependencies do |dependent, dep|
|
missing_dependencies = f.missing_dependencies(hide: hide)
|
||||||
if dep.optional? || dep.recommended?
|
|
||||||
tab = Tab.for_formula(dependent)
|
|
||||||
Dependency.prune unless tab.with?(dep)
|
|
||||||
elsif dep.build?
|
|
||||||
Dependency.prune
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
missing_deps.map!(&:to_formula)
|
unless missing_dependencies.empty?
|
||||||
missing_deps.reject! do |d|
|
yield f.full_name, missing_dependencies if block_given?
|
||||||
!hide.include?(d.name) && d.installed_prefixes.any?
|
missing[f.full_name] = missing_dependencies
|
||||||
end
|
|
||||||
|
|
||||||
unless missing_deps.empty?
|
|
||||||
yield f.full_name, missing_deps if block_given?
|
|
||||||
missing[f.full_name] = missing_deps
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
missing
|
missing
|
||||||
|
|||||||
@ -1466,6 +1466,26 @@ class Formula
|
|||||||
recursive_dependencies.reject(&:build?)
|
recursive_dependencies.reject(&:build?)
|
||||||
end
|
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
|
# @private
|
||||||
def to_hash
|
def to_hash
|
||||||
hsh = {
|
hsh = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user