refactoring style to resolve the last discussions

This commit is contained in:
thibhero 2025-06-18 16:05:19 -04:00
parent fe06e04e28
commit 19901b5332
5 changed files with 63 additions and 75 deletions

View File

@ -353,17 +353,13 @@ module Homebrew
dry_run: args.dry_run?,
)
if args.ask?
formulae_dependencies = Install.collect_dependencies(formulae_installer, dependants)
# Main block: if asking the user is enabled, show dependency and size information.
Install.ask_formulae(formulae_dependencies, args: args)
end
Install.ask_formulae(formulae_installer, dependants, args: args) if args.ask?
Install.install_formulae(formulae_installer,
dry_run: args.dry_run?,
verbose: args.verbose?)
if dependants.present?
Upgrade.upgrade_dependents(
dependants, installed_formulae,
flags: args.flags_only,
@ -378,7 +374,6 @@ module Homebrew
quiet: args.quiet?,
verbose: args.verbose?
)
end
Cleanup.periodic_clean!(dry_run: args.dry_run?)

View File

@ -169,12 +169,8 @@ module Homebrew
formulae_installer = formulae_kegs.map(&:formula_installer)
if args.ask?
formulae_dependencies = Install.collect_dependencies(formulae_installer, dependants)
# Main block: if asking the user is enabled, show dependency and size information.
Install.ask_formulae(formulae_dependencies, args: args)
end
Install.ask_formulae(formulae_installer, dependants, args: args) if args.ask?
formulae_kegs.each do |f|
Homebrew::Reinstall.reinstall_formula(
@ -194,7 +190,6 @@ module Homebrew
Cleanup.install_formula_clean!(f.formula)
end
if dependants.present?
Upgrade.upgrade_dependents(
dependants, formulae,
flags: args.flags_only,
@ -209,7 +204,6 @@ module Homebrew
verbose: args.verbose?
)
end
end
if casks.any?
Install.ask_casks casks if args.ask?

View File

@ -252,17 +252,13 @@ module Homebrew
verbose: args.verbose?,
)
if args.ask?
formulae_dependencies = Install.collect_dependencies(formulae_installer, dependants)
# Main block: if asking the user is enabled, show dependency and size information.
Install.ask_formulae(formulae_dependencies, args: args)
end
Install.ask_formulae(formulae_installer, dependants, args: args) if args.ask?
Upgrade.upgrade_formulae(formulae_installer,
dry_run: args.dry_run?,
verbose: args.verbose?)
if dependants.present?
Upgrade.upgrade_dependents(
dependants, formulae_to_install,
flags: args.flags_only,
@ -277,7 +273,6 @@ module Homebrew
quiet: args.quiet?,
verbose: args.verbose?
)
end
true
end

View File

@ -353,19 +353,11 @@ module Homebrew
puts formula_names.join(" ")
end
def collect_dependencies(formulae_installer, dependants)
formulae_dependencies = formulae_installer.flat_map do |f|
[f.formula, f.compute_dependencies.flatten.filter do |c|
c.is_a? Dependency
end.flat_map(&:to_formula)]
end.flatten.uniq
formulae_dependencies.concat(dependants.upgradeable) if dependants&.upgradeable
formulae_dependencies
end
# If asking the user is enabled, show dependency and size information.
def ask_formulae(formulae, args:)
return if formulae.empty?
def ask_formulae(formulae_installer, dependants, args:)
return if formulae_installer.empty?
formulae = collect_dependencies(formulae_installer, dependants)
ohai "Looking for bottles..."
@ -469,6 +461,16 @@ module Homebrew
installed: total_installed_size,
net: total_net_size }
end
def collect_dependencies(formulae_installer, dependants)
formulae_dependencies = formulae_installer.flat_map do |f|
[f.formula, f.compute_dependencies.flatten.filter do |c|
c.is_a? Dependency
end.flat_map(&:to_formula)]
end.flatten.uniq
formulae_dependencies.concat(dependants.upgradeable) if dependants&.upgradeable
formulae_dependencies
end
end
end
end

View File

@ -329,6 +329,8 @@ module Homebrew
debug: false,
quiet: false,
verbose: false)
return if deps.blank?
upgradeable = deps.upgradeable
pinned = deps.pinned
skipped = deps.skipped