uses: fix --installed with outdated versions

With that option iterate only over `Formula.installed`, otherwise
iterate over `Formula`. This is faster than iterating over all the
formulae and checking if it's installed.

Fixes Homebrew/homebrew#27259.
Closes Homebrew/homebrew#27295.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Jaime Marquínez Ferrándiz 2014-03-07 16:56:17 +01:00 committed by Jack Nagel
parent f155b0570e
commit 342ed1d163

View File

@ -8,13 +8,12 @@ module Homebrew extend self
def uses
raise FormulaUnspecifiedError if ARGV.named.empty?
formulae = ARGV.formulae
used_formulae = ARGV.formulae
formulae = (ARGV.include? "--installed") ? Formula.installed : Formula
uses = []
Formula.each do |f|
next if ARGV.include? "--installed" and not f.installed?
formulae.all? do |ff|
formulae.each do |f|
used_formulae.all? do |ff|
if ARGV.flag? '--recursive'
if f.recursive_dependencies.any? { |dep| dep.name == ff.name }
uses << f.to_s