diff --git a/Library/Homebrew/cmd/deps.rb b/Library/Homebrew/cmd/deps.rb index 4c5dbb93251d31328119929846d1f6e4cbc4442d..dfdd2d9f86af9ea5c3a4be21718a7c559001f854 100644 --- a/Library/Homebrew/cmd/deps.rb +++ b/Library/Homebrew/cmd/deps.rb @@ -85,10 +85,22 @@ module Homebrew if recursive deps = f.recursive_dependencies do |dependent, dep| - Dependency.prune if ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } && !dependent.build.with?(dep) + if dep.recommended? + Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) + elsif dep.optional? + Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep) + elsif dep.build? + Dependency.prune unless includes.include?("build?") + end end reqs = f.recursive_requirements do |dependent, req| - Requirement.prune if ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } && !dependent.build.with?(req) + if req.recommended? + Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) + elsif req.optional? + Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) + elsif req.build? + Requirement.prune unless includes.include?("build?") + end end else deps = f.deps.reject do |dep| diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb index 045e0a94f9c845e13da3f0fbe45a8d0c44b08fed..ff7f7529efa939b8eae95427007de8a582ce5077 100644 --- a/Library/Homebrew/cmd/uses.rb +++ b/Library/Homebrew/cmd/uses.rb @@ -48,10 +48,22 @@ module Homebrew begin if recursive deps = f.recursive_dependencies do |dependent, dep| - Dependency.prune if ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } && !dependent.build.with?(dep) + if dep.recommended? + Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) + elsif dep.optional? + Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep) + elsif dep.build? + Dependency.prune unless includes.include?("build?") + end end reqs = f.recursive_requirements do |dependent, req| - Requirement.prune if ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } && !dependent.build.with?(req) + if req.recommended? + Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) + elsif req.optional? + Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) + elsif req.build? + Requirement.prune unless includes.include?("build?") + end end deps.any? { |dep| dep.to_formula.full_name == ff.full_name rescue dep.name == ff.name } || reqs.any? { |req| req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) }