dependency_helpers: include required & use public_send
- Use .required? instead of .tags.empty? - use .public_send - modify .reject_ignores to be .select_includes - checks ignores first now - Don't use runtime deps with --missing in `brew deps` command
This commit is contained in:
parent
3cba4cbc19
commit
e314a43754
@ -90,7 +90,8 @@ module Homebrew
|
||||
!args.include_build? &&
|
||||
!args.include_test? &&
|
||||
!args.include_optional? &&
|
||||
!args.skip_recommended?
|
||||
!args.skip_recommended? &&
|
||||
!args.missing?
|
||||
|
||||
if args.tree? || args.graph?
|
||||
dependents = if args.named.present?
|
||||
@ -197,8 +198,8 @@ module Homebrew
|
||||
deps ||= recursive_includes(Dependency, dependency, includes, ignores)
|
||||
reqs = recursive_includes(Requirement, dependency, includes, ignores)
|
||||
else
|
||||
deps ||= reject_ignores(dependency.deps, ignores, includes)
|
||||
reqs = reject_ignores(dependency.requirements, ignores, includes)
|
||||
deps ||= select_includes(dependency.deps, ignores, includes)
|
||||
reqs = select_includes(dependency.requirements, ignores, includes)
|
||||
end
|
||||
|
||||
deps + reqs.to_a
|
||||
@ -269,8 +270,8 @@ module Homebrew
|
||||
def self.dependables(formula, args:)
|
||||
includes, ignores = args_includes_ignores(args)
|
||||
deps = @use_runtime_dependencies ? formula.runtime_dependencies : formula.deps
|
||||
deps = reject_ignores(deps, ignores, includes)
|
||||
reqs = reject_ignores(formula.requirements, ignores, includes) if args.include_requirements?
|
||||
deps = select_includes(deps, ignores, includes)
|
||||
reqs = select_includes(formula.requirements, ignores, includes) if args.include_requirements?
|
||||
reqs ||= []
|
||||
reqs + deps
|
||||
end
|
||||
|
@ -129,7 +129,7 @@ module Homebrew
|
||||
deps = if recursive
|
||||
recursive_includes(Dependency, d, includes, ignores)
|
||||
else
|
||||
reject_ignores(d.deps, ignores, includes)
|
||||
select_includes(d.deps, ignores, includes)
|
||||
end
|
||||
|
||||
used_formulae.all? do |ff|
|
||||
|
@ -8,7 +8,7 @@ require "cask_dependent"
|
||||
# @api private
|
||||
module DependenciesHelpers
|
||||
def args_includes_ignores(args)
|
||||
includes = [:recommended?] # included by default
|
||||
includes = [:required?, :recommended?] # included by default
|
||||
includes << :build? if args.include_build?
|
||||
includes << :test? if args.include_test?
|
||||
includes << :optional? if args.include_optional?
|
||||
@ -26,14 +26,12 @@ module DependenciesHelpers
|
||||
cache_key = "recursive_includes_#{includes}_#{ignores}"
|
||||
|
||||
klass.expand(root_dependent, cache_key: cache_key) do |dependent, dep|
|
||||
klass.prune if ignores.any? { |ignore| dep.send(ignore) }
|
||||
|
||||
# NOTE: Untagged dependencies are runtime dependencies and are included by default.
|
||||
klass.prune if !dep.tags.empty? && includes.none? do |include|
|
||||
klass.prune if ignores.any? { |ignore| dep.public_send(ignore) }
|
||||
klass.prune if includes.none? do |include|
|
||||
# Ignore indirect test dependencies
|
||||
next if include == :test? && dependent != root_dependent
|
||||
|
||||
dep.send(include)
|
||||
dep.public_send(include)
|
||||
end
|
||||
|
||||
# If a tap isn't installed, we can't find the dependencies of one of
|
||||
@ -42,11 +40,11 @@ module DependenciesHelpers
|
||||
end
|
||||
end
|
||||
|
||||
def reject_ignores(dependables, ignores, includes)
|
||||
dependables.reject do |dep|
|
||||
next false unless ignores.any? { |ignore| dep.send(ignore) }
|
||||
def select_includes(dependables, ignores, includes)
|
||||
dependables.select do |dep|
|
||||
next false if ignores.any? { |ignore| dep.public_send(ignore) }
|
||||
|
||||
includes.none? { |include| dep.send(include) }
|
||||
includes.any? { |include| dep.public_send(include) }
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user