aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorAlyssa Ross2016-09-15 16:01:18 +0100
committerAlyssa Ross2016-09-18 19:58:09 +0100
commit2a683f2569614850f79534a8547fd96cc52c7850 (patch)
treecd89a2f42b59d337cda690ed2550c28772b36344 /Library/Homebrew/cmd
parent3d559fa79641735193636cbf6240c082e6ca171c (diff)
downloadbrew-2a683f2569614850f79534a8547fd96cc52c7850.tar.bz2
upgrade, outdated: follow alias changes
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/outdated.rb21
-rw-r--r--Library/Homebrew/cmd/upgrade.rb28
2 files changed, 33 insertions, 16 deletions
diff --git a/Library/Homebrew/cmd/outdated.rb b/Library/Homebrew/cmd/outdated.rb
index 7afa41df4..f9739cd7a 100644
--- a/Library/Homebrew/cmd/outdated.rb
+++ b/Library/Homebrew/cmd/outdated.rb
@@ -43,15 +43,26 @@ module Homebrew
outdated_formulae.each do |f|
if verbose
- outdated_versions = f.outdated_versions(fetch_head: fetch_head)
- current_version = if f.head? && outdated_versions.any? { |v| v.to_s == f.pkg_version.to_s }
+ outdated_kegs = f.outdated_kegs(fetch_head: fetch_head)
+
+ current_version = if f.alias_changed?
+ 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 }
+ # There is a newer HEAD but the version number has not changed.
"latest HEAD"
else
f.pkg_version.to_s
end
- puts "#{f.full_name} (#{outdated_versions.join(", ")}) < #{current_version}"
+
+ outdated_versions = outdated_kegs.
+ group_by(&:name).
+ sort_by(&:first).
+ map { |name, kegs| "#{name} (#{kegs.map(&:version) * ", "})" } * ", "
+
+ puts "#{outdated_versions} < #{current_version}"
else
- puts f.full_name
+ puts f.full_installed_specified_name
end
end
end
@@ -62,7 +73,7 @@ module Homebrew
outdated_formulae = formulae.select { |f| f.outdated?(fetch_head: fetch_head) }
outdated = outdated_formulae.each do |f|
- outdated_versions = f.outdated_versions(fetch_head: fetch_head)
+ outdated_versions = f.outdated_kegs(fetch_head: fetch_head).map(&:version)
current_version = if f.head? && outdated_versions.any? { |v| v.to_s == f.pkg_version.to_s }
"HEAD"
else
diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb
index 6968fbda8..c56a73384 100644
--- a/Library/Homebrew/cmd/upgrade.rb
+++ b/Library/Homebrew/cmd/upgrade.rb
@@ -37,10 +37,10 @@ module Homebrew
(ARGV.resolved_formulae - outdated).each do |f|
versions = f.installed_kegs.map(&:version)
if versions.empty?
- onoe "#{f.full_name} not installed"
+ onoe "#{f.full_specified_name} not installed"
else
version = versions.max
- onoe "#{f.full_name} #{version} already installed"
+ onoe "#{f.full_specified_name} #{version} already installed"
end
end
exit 1 if outdated.empty?
@@ -51,19 +51,21 @@ module Homebrew
outdated -= pinned
end
- if outdated.empty?
+ formulae_to_install = outdated.map(&:latest_formula)
+
+ if formulae_to_install.empty?
oh1 "No packages to upgrade"
else
- oh1 "Upgrading #{outdated.length} outdated package#{plural(outdated.length)}, with result:"
- puts outdated.map { |f| "#{f.full_name} #{f.pkg_version}" } * ", "
+ oh1 "Upgrading #{formulae_to_install.length} outdated package#{plural(formulae_to_install.length)}, with result:"
+ puts formulae_to_install.map { |f| "#{f.full_specified_name} #{f.pkg_version}" } * ", "
end
unless upgrade_pinned? || pinned.empty?
oh1 "Not upgrading #{pinned.length} pinned package#{plural(pinned.length)}:"
- puts pinned.map { |f| "#{f.full_name} #{f.pkg_version}" } * ", "
+ puts pinned.map { |f| "#{f.full_specified_name} #{f.pkg_version}" } * ", "
end
- outdated.each do |f|
+ formulae_to_install.each do |f|
upgrade_formula(f)
next unless ARGV.include?("--cleanup")
next unless f.installed?
@@ -76,7 +78,11 @@ module Homebrew
end
def upgrade_formula(f)
- outdated_keg = Keg.new(f.linked_keg.resolved_path) if f.linked_keg.directory?
+ formulae_maybe_with_kegs = [f] + f.old_installed_formulae
+ outdated_kegs = formulae_maybe_with_kegs.
+ map(&:linked_keg).
+ select(&:directory?).
+ map { |k| Keg.new(k.resolved_path) }
fi = FormulaInstaller.new(f)
fi.options = f.build.used_options
@@ -87,12 +93,12 @@ module Homebrew
fi.debug = ARGV.debug?
fi.prelude
- oh1 "Upgrading #{f.full_name}"
+ oh1 "Upgrading #{f.full_specified_name}"
# first we unlink the currently active keg for this formula otherwise it is
# possible for the existing build to interfere with the build we are about to
# do! Seriously, it happens!
- outdated_keg.unlink if outdated_keg
+ outdated_kegs.each(&:unlink)
fi.install
fi.finish
@@ -117,7 +123,7 @@ module Homebrew
ensure
# restore previous installation state if build failed
begin
- outdated_keg.link if outdated_keg && !f.installed?
+ outdated_kegs.each(&:link) if !f.installed?
rescue
nil
end