Merge pull request #8461 from reitermarkus/document-upgrade

Refactor and document `Upgrade`.
This commit is contained in:
Markus Reiter 2020-08-25 02:24:23 +02:00 committed by GitHub
commit aaf6ccfbf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 217 additions and 212 deletions

View File

@ -263,7 +263,7 @@ module Homebrew
Cleanup.install_formula_clean!(f) Cleanup.install_formula_clean!(f)
end end
check_installed_dependents(args: args) Upgrade.check_installed_dependents(args: args)
Homebrew.messages.display_messages(display_times: args.display_times?) Homebrew.messages.display_messages(display_times: args.display_times?)
rescue FormulaUnreadableError, FormulaClassUnavailableError, rescue FormulaUnreadableError, FormulaClassUnavailableError,

View File

@ -72,7 +72,7 @@ module Homebrew
Cleanup.install_formula_clean!(f) Cleanup.install_formula_clean!(f)
end end
check_installed_dependents(args: args) Upgrade.check_installed_dependents(args: args)
Homebrew.messages.display_messages(display_times: args.display_times?) Homebrew.messages.display_messages(display_times: args.display_times?)

View File

@ -137,9 +137,9 @@ module Homebrew
puts formulae_upgrades.join("\n") puts formulae_upgrades.join("\n")
end end
upgrade_formulae(formulae_to_install, args: args) Upgrade.upgrade_formulae(formulae_to_install, args: args)
check_installed_dependents(args: args) Upgrade.check_installed_dependents(args: args)
Homebrew.messages.display_messages(display_times: args.display_times?) Homebrew.messages.display_messages(display_times: args.display_times?)
end end

View File

@ -7,6 +7,10 @@ require "messages"
require "cleanup" require "cleanup"
module Homebrew module Homebrew
# Helper functions for upgrading formulae.
#
# @api private
module Upgrade
module_function module_function
def upgrade_formulae(formulae_to_install, args:) def upgrade_formulae(formulae_to_install, args:)
@ -47,8 +51,7 @@ module Homebrew
end end
formulae_maybe_with_kegs = [f] + f.old_installed_formulae formulae_maybe_with_kegs = [f] + f.old_installed_formulae
outdated_kegs = formulae_maybe_with_kegs outdated_kegs = formulae_maybe_with_kegs.map(&:linked_keg)
.map(&:linked_keg)
.select(&:directory?) .select(&:directory?)
.map { |k| Keg.new(k.resolved_path) } .map { |k| Keg.new(k.resolved_path) }
linked_kegs = outdated_kegs.select(&:linked?) linked_kegs = outdated_kegs.select(&:linked?)
@ -115,6 +118,7 @@ module Homebrew
nil nil
end end
end end
private_class_method :upgrade_formula
def check_installed_dependents(args:) def check_installed_dependents(args:)
installed_formulae = FormulaInstaller.installed.to_a installed_formulae = FormulaInstaller.installed.to_a
@ -233,7 +237,6 @@ module Homebrew
end end
end end
# @private
def depends_on(a, b) def depends_on(a, b)
if a.opt_or_installed_prefix_keg if a.opt_or_installed_prefix_keg
&.runtime_dependencies &.runtime_dependencies
@ -243,4 +246,6 @@ module Homebrew
a <=> b a <=> b
end end
end end
private_class_method :depends_on
end
end end