Skip to content

Commit

Permalink
Don't lie about upgrading up-to-date formulae
Browse files Browse the repository at this point in the history
Usually, the "foo-version already installed" error is printed by
FormulaInstaller. However, if an up-to-date formula that has outdated
deps is passed on the command line, we proceed to upgrade the deps and
then print a message saying that the formulae given on the command line
is already installed.

Catch this earlier, when the outdated list is being populated, print an
appropriate message, and skip the up-to-date formula.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
  • Loading branch information
jacknagel committed Aug 19, 2012
1 parent 07d6ace commit 9526817
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Library/Homebrew/cmd/upgrade.rb
Expand Up @@ -21,7 +21,9 @@ def upgrade
Homebrew.outdated_brews
else
ARGV.formulae.select do |f|
unless f.rack.exist? and not f.rack.children.empty?
if f.installed?
onoe "#{f}-#{f.installed_version} already installed"
elsif not f.rack.exist? or f.rack.children.empty?
onoe "#{f} not installed"
else
true
Expand Down
5 changes: 5 additions & 0 deletions Library/Homebrew/formula.rb
Expand Up @@ -105,6 +105,11 @@ def installed_prefix
end
end

def installed_version
require 'keg'
Keg.new(installed_prefix).version
end

def prefix
validate_variable :name
validate_variable :version
Expand Down
3 changes: 1 addition & 2 deletions Library/Homebrew/formula_installer.rb
Expand Up @@ -24,8 +24,7 @@ def initialize ff, tab=nil

def check_install_sanity
if f.installed?
keg = Keg.new(f.installed_prefix)
raise CannotInstallFormulaError, "#{f}-#{keg.version} already installed"
raise CannotInstallFormulaError, "#{f}-#{f.installed_version} already installed"
end

# Building head-only without --HEAD is an error
Expand Down

0 comments on commit 9526817

Please sign in to comment.