dependency::expand: only prune missing deps with flag

This commit is contained in:
Rylan Polster 2021-06-18 12:03:22 -04:00
parent 2760d981d3
commit b096bf1fed
No known key found for this signature in database
GPG Key ID: 46A744940CFF4D64
3 changed files with 12 additions and 11 deletions

View File

@ -15,8 +15,8 @@ class CaskDependent
@cask.full_name @cask.full_name
end end
def runtime_dependencies def runtime_dependencies(ignore_missing: false)
recursive_dependencies recursive_dependencies ignore_missing: ignore_missing
end end
def deps def deps
@ -43,8 +43,8 @@ class CaskDependent
end end
end end
def recursive_dependencies(&block) def recursive_dependencies(ignore_missing: false, &block)
Dependency.expand(self, &block) Dependency.expand(self, ignore_missing: ignore_missing, &block)
end end
def recursive_requirements(&block) def recursive_requirements(&block)

View File

@ -98,7 +98,7 @@ class Dependency
# the list. # the list.
# The default filter, which is applied when a block is not given, omits # The default filter, which is applied when a block is not given, omits
# optionals and recommendeds based on what the dependent has asked for # optionals and recommendeds based on what the dependent has asked for
def expand(dependent, deps = dependent.deps, cache_key: nil, &block) def expand(dependent, deps = dependent.deps, cache_key: nil, ignore_missing: false, &block)
# Keep track dependencies to avoid infinite cyclic dependency recursion. # Keep track dependencies to avoid infinite cyclic dependency recursion.
@expand_stack ||= [] @expand_stack ||= []
@expand_stack.push dependent.name @expand_stack.push dependent.name
@ -113,19 +113,19 @@ class Dependency
deps.each do |dep| deps.each do |dep|
next if dependent.name == dep.name next if dependent.name == dep.name
case action(dependent, dep, &block) case action(dependent, dep, ignore_missing: ignore_missing, &block)
when :prune when :prune
next next
when :skip when :skip
next if @expand_stack.include? dep.name next if @expand_stack.include? dep.name
expanded_deps.concat(expand(dep.to_formula, cache_key: cache_key, &block)) expanded_deps.concat(expand(dep.to_formula, cache_key: cache_key, ignore_missing: ignore_missing, &block))
when :keep_but_prune_recursive_deps when :keep_but_prune_recursive_deps
expanded_deps << dep expanded_deps << dep
else else
next if @expand_stack.include? dep.name next if @expand_stack.include? dep.name
expanded_deps.concat(expand(dep.to_formula, cache_key: cache_key, &block)) expanded_deps.concat(expand(dep.to_formula, cache_key: cache_key, ignore_missing: ignore_missing, &block))
expanded_deps << dep expanded_deps << dep
end end
end end
@ -137,9 +137,9 @@ class Dependency
@expand_stack.pop @expand_stack.pop
end end
def action(dependent, dep, &block) def action(dependent, dep, ignore_missing: false, &block)
catch(:action) do catch(:action) do
prune if dep.unavailable_core_formula? prune if ignore_missing && dep.unavailable_core_formula?
if block if block
yield dependent, dep yield dependent, dep

View File

@ -50,7 +50,8 @@ module InstalledDependents
when Formula when Formula
dependent.missing_dependencies(hide: keg_names) dependent.missing_dependencies(hide: keg_names)
when Cask::Cask when Cask::Cask
CaskDependent.new(dependent).runtime_dependencies.map(&:to_formula) # When checking for cask dependents, we don't care about missing dependencies
CaskDependent.new(dependent).runtime_dependencies(ignore_missing: true).map(&:to_formula)
end end
required_kegs = required.map do |f| required_kegs = required.map do |f|