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
commit7fa5e80567cc96bc053cc1a68d8d8b50269d01b6 (patch)
treed8ded3e583913f1960bbf6da18929304d4a6094d /Library
parent2b4141166dab9f41300ece0a06a42b5349281a7e (diff)
downloadhomebrew-7fa5e80567cc96bc053cc1a68d8d8b50269d01b6.tar.bz2
brew-leaves: resolve dependency graph for installed formulae only
Closes #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 }