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,32 +353,27 @@ 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
# Main block: if asking the user is enabled, show dependency and size information.
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,
dry_run: args.dry_run?,
force_bottle: args.force_bottle?,
build_from_source_formulae: args.build_from_source_formulae,
interactive: args.interactive?,
keep_tmp: args.keep_tmp?,
debug_symbols: args.debug_symbols?,
force: args.force?,
debug: args.debug?,
quiet: args.quiet?,
verbose: args.verbose?
)
end
Upgrade.upgrade_dependents(
dependants, installed_formulae,
flags: args.flags_only,
dry_run: args.dry_run?,
force_bottle: args.force_bottle?,
build_from_source_formulae: args.build_from_source_formulae,
interactive: args.interactive?,
keep_tmp: args.keep_tmp?,
debug_symbols: args.debug_symbols?,
force: args.force?,
debug: args.debug?,
quiet: args.quiet?,
verbose: args.verbose?
)
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
# Main block: if asking the user is enabled, show dependency and size information.
Install.ask_formulae(formulae_installer, dependants, args: args) if args.ask?
formulae_kegs.each do |f|
Homebrew::Reinstall.reinstall_formula(
@ -194,21 +190,19 @@ module Homebrew
Cleanup.install_formula_clean!(f.formula)
end
if dependants.present?
Upgrade.upgrade_dependents(
dependants, formulae,
flags: args.flags_only,
force_bottle: args.force_bottle?,
build_from_source_formulae: args.build_from_source_formulae,
interactive: args.interactive?,
keep_tmp: args.keep_tmp?,
debug_symbols: args.debug_symbols?,
force: args.force?,
debug: args.debug?,
quiet: args.quiet?,
verbose: args.verbose?
)
end
Upgrade.upgrade_dependents(
dependants, formulae,
flags: args.flags_only,
force_bottle: args.force_bottle?,
build_from_source_formulae: args.build_from_source_formulae,
interactive: args.interactive?,
keep_tmp: args.keep_tmp?,
debug_symbols: args.debug_symbols?,
force: args.force?,
debug: args.debug?,
quiet: args.quiet?,
verbose: args.verbose?
)
end
if casks.any?

View File

@ -252,32 +252,27 @@ 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
# Main block: if asking the user is enabled, show dependency and size information.
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,
dry_run: args.dry_run?,
force_bottle: args.force_bottle?,
build_from_source_formulae: args.build_from_source_formulae,
interactive: args.interactive?,
keep_tmp: args.keep_tmp?,
debug_symbols: args.debug_symbols?,
force: args.force?,
debug: args.debug?,
quiet: args.quiet?,
verbose: args.verbose?
)
end
Upgrade.upgrade_dependents(
dependants, formulae_to_install,
flags: args.flags_only,
dry_run: args.dry_run?,
force_bottle: args.force_bottle?,
build_from_source_formulae: args.build_from_source_formulae,
interactive: args.interactive?,
keep_tmp: args.keep_tmp?,
debug_symbols: args.debug_symbols?,
force: args.force?,
debug: args.debug?,
quiet: args.quiet?,
verbose: args.verbose?
)
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