outdated/upgrade: fix upgrade alias edge case.

If you're going to follow an alias to find the outdated formula then
ensure that the latest one isn't already installed.

Fixes https://github.com/Homebrew/homebrew-core/issues/63971
This commit is contained in:
Mike McQuaid 2020-11-05 20:33:51 +00:00
parent 0e36cdcf0f
commit 0606c9fd82
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
2 changed files with 9 additions and 2 deletions

View File

@ -97,7 +97,7 @@ module Homebrew
if verbose?
outdated_kegs = f.outdated_kegs(fetch_head: args.fetch_HEAD?)
current_version = if f.alias_changed?
current_version = if f.alias_changed? && !f.latest_formula.latest_version_installed?
latest = f.latest_formula
"#{latest.name} (#{latest.pkg_version})"
elsif f.head? && outdated_kegs.any? { |k| k.version.to_s == f.pkg_version.to_s }

View File

@ -137,7 +137,14 @@ module Homebrew
pinned = outdated.select(&:pinned?)
outdated -= pinned
formulae_to_install = outdated.map(&:latest_formula)
formulae_to_install = outdated.map do |f|
f_latest = f.latest_formula
if f_latest.latest_version_installed?
f
else
f_latest
end
end
if !pinned.empty? && !args.ignore_pinned?
ofail "Not upgrading #{pinned.count} pinned #{"package".pluralize(pinned.count)}:"