From 95268173419a1b28d696cc969dca2d0b0a6e5102 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sat, 18 Aug 2012 18:37:32 -0500 Subject: [PATCH] Don't lie about upgrading up-to-date formulae 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 --- Library/Homebrew/cmd/upgrade.rb | 4 +++- Library/Homebrew/formula.rb | 5 +++++ Library/Homebrew/formula_installer.rb | 3 +-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index 1afef1261a1f..7ec02a0b5898 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -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 diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index d6f9f8f7b837..57e5f76de6e5 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -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 diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 7421cabe0821..06ac93975cbc 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -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