aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorAlyssa Ross2017-01-16 23:23:09 +0000
committerAlyssa Ross2017-01-16 23:28:26 +0000
commit9475622c070d941b044f94eafef0d46aa29568bc (patch)
treed2df1ff4942deb64b49246441eda17446565ff7e /Library/Homebrew/cmd
parent0b216798bb33e63e7b9da795925f610f93cc1e33 (diff)
downloadbrew-9475622c070d941b044f94eafef0d46aa29568bc.tar.bz2
uses: restore formula-level exception handler
This is a temporary measure until: - #1862 is merged - I can a test on `brew uses` against every formula in the official taps to verify that exceptions are no longer raised.
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/uses.rb79
1 files changed, 42 insertions, 37 deletions
diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb
index f9af36754..20fc146bf 100644
--- a/Library/Homebrew/cmd/uses.rb
+++ b/Library/Homebrew/cmd/uses.rb
@@ -47,49 +47,54 @@ module Homebrew
uses = formulae.select do |f|
used_formulae.all? do |ff|
- if recursive
- deps = f.recursive_dependencies do |dependent, 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
+ begin
+ if recursive
+ deps = f.recursive_dependencies do |dependent, 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
- # If a tap isn't installed, we can't find the dependencies of one
- # its formulae, and an exception will be thrown if we try.
- if dep.is_a?(TapDependency) && !dep.tap.installed?
- Dependency.keep_but_prune_recursive_deps
+ # If a tap isn't installed, we can't find the dependencies of one
+ # its formulae, and an exception will be thrown if we try.
+ if dep.is_a?(TapDependency) && !dep.tap.installed?
+ Dependency.keep_but_prune_recursive_deps
+ end
end
- end
- reqs = f.recursive_requirements do |dependent, 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?")
+ reqs = f.recursive_requirements do |dependent, 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|
+ ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) }
+ end
+ reqs = f.requirements.reject do |req|
+ ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) }
end
end
- else
- deps = f.deps.reject do |dep|
- ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) }
- end
- reqs = f.requirements.reject do |req|
- ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) }
- end
- end
- next true if deps.any? do |dep|
- begin
- dep.to_formula.full_name == ff.full_name
- rescue
- dep.name == ff.name
+ next true if deps.any? do |dep|
+ begin
+ dep.to_formula.full_name == ff.full_name
+ rescue
+ dep.name == ff.name
+ end
end
- end
- reqs.any? do |req|
- req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula)
+ reqs.any? do |req|
+ req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula)
+ end
+ rescue FormulaUnavailableError
+ # Silently ignore this case as we don't care about things used in
+ # taps that aren't currently tapped.
end
end
end