aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorTroels Thomsen2013-05-16 20:10:00 +0200
committerJack Nagel2013-05-19 18:41:49 -0500
commitebedd3d57fc1f94210ccbfd256722649f88c1c91 (patch)
treef90d4b5cca7d1583b3ce394934a69533450f3101 /Library
parent4276d03fe47a535c783c73dcb8d813de849e0b1e (diff)
downloadbrew-ebedd3d57fc1f94210ccbfd256722649f88c1c91.tar.bz2
brew-leaves: resolve dependency graph for installed formulae only
Closes Homebrew/homebrew#19870. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library')
-rwxr-xr-xLibrary/Contributions/cmd/brew-leaves.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/Library/Contributions/cmd/brew-leaves.rb b/Library/Contributions/cmd/brew-leaves.rb
index f94809c9d..3da55c019 100755
--- a/Library/Contributions/cmd/brew-leaves.rb
+++ b/Library/Contributions/cmd/brew-leaves.rb
@@ -4,10 +4,10 @@
require 'formula'
-def get_used_by
+def get_used_by(formulae)
used_by = {}
- Formula.each do |f|
- next if f.deps == nil
+ formulae.each do |f|
+ next if f.nil? or f.deps.nil?
f.deps.each do |dep|
_deps = used_by[dep.to_s] || []
@@ -19,8 +19,17 @@ def get_used_by
return used_by
end
-deps_graph = get_used_by()
installed = HOMEBREW_CELLAR.children.select { |pn| pn.directory? }.collect { |pn| pn.basename.to_s }
+installed_formulae = installed.collect do |pn|
+ begin
+ Formula.factory(pn)
+ rescue FormulaUnavailableError
+ # Don't complain about directories from DIY installs
+ end
+end
+
+deps_graph = get_used_by(installed_formulae)
+
installed.each do |name|
deps = deps_graph[name] || []
puts name unless deps.any? { |dep| installed.include? dep.to_s }