corrected code with brew typecheck

This commit is contained in:
thibhero 2025-02-11 18:53:10 -05:00
parent a111139682
commit 9891653aa8
2 changed files with 22 additions and 26 deletions

View File

@ -174,7 +174,7 @@ module Homebrew
end end
# Add any installed formula that depends on one of the sized formulae and is outdated. # Add any installed formula that depends on one of the sized formulae and is outdated.
unless Homebrew::EnvConfig.no_installed_dependents_check? || !check_dep if !Homebrew::EnvConfig.no_installed_dependents_check? && check_dep
installed_outdated = Formula.installed.select do |installed_formula| installed_outdated = Formula.installed.select do |installed_formula|
installed_formula.outdated? && installed_formula.outdated? &&
installed_formula.deps.any? { |dep| sized_formulae.include?(dep.to_formula) } installed_formula.deps.any? { |dep| sized_formulae.include?(dep.to_formula) }
@ -183,7 +183,7 @@ module Homebrew
end end
# Uniquify based on a string representation (or any unique identifier) # Uniquify based on a string representation (or any unique identifier)
sized_formulae.uniq { |f| f.to_s } sized_formulae.uniq(&:to_s)
} }
# Compute the total sizes (download, installed, and net) for the given formulae. # Compute the total sizes (download, installed, and net) for the given formulae.
@ -202,12 +202,10 @@ module Homebrew
total_installed_size += bottle.installed_size.to_i if bottle.installed_size total_installed_size += bottle.installed_size.to_i if bottle.installed_size
# Sum disk usage for all installed kegs of the formula. # Sum disk usage for all installed kegs of the formula.
if formula.installed_kegs.any? next if formula.installed_kegs.none?
kegs_dep_size = formula.installed_kegs.sum { |keg| keg.disk_usage.to_i } kegs_dep_size = formula.installed_kegs.sum { |keg| keg.disk_usage.to_i }
if bottle.installed_size total_net_size += bottle.installed_size.to_i - kegs_dep_size if bottle.installed_size
total_net_size += bottle.installed_size.to_i - kegs_dep_size
end
end
end end
{ download: total_download_size, { download: total_download_size,

View File

@ -242,8 +242,8 @@ module Homebrew
# 1. The original formulae to install. # 1. The original formulae to install.
# 2. Their outdated dependents (subject to pruning criteria). # 2. Their outdated dependents (subject to pruning criteria).
# 3. Optionally, any installed formula that depends on one of these and is outdated. # 3. Optionally, any installed formula that depends on one of these and is outdated.
compute_sized_formulae = lambda { |formulae_to_install, check_dep: true| compute_sized_formulae = lambda { |f, check_dep: true|
sized_formulae = formulae_to_install.flat_map do |formula| sized_formulae = f.flat_map do |formula|
# Always include the formula itself. # Always include the formula itself.
formula_list = [formula] formula_list = [formula]
@ -264,7 +264,7 @@ module Homebrew
end end
# Add any installed formula that depends on one of the sized formulae and is outdated. # Add any installed formula that depends on one of the sized formulae and is outdated.
unless Homebrew::EnvConfig.no_installed_dependents_check? || !check_dep if !Homebrew::EnvConfig.no_installed_dependents_check? && check_dep
installed_outdated = Formula.installed.select do |installed_formula| installed_outdated = Formula.installed.select do |installed_formula|
installed_formula.outdated? && installed_formula.outdated? &&
installed_formula.deps.any? { |dep| sized_formulae.include?(dep.to_formula) } installed_formula.deps.any? { |dep| sized_formulae.include?(dep.to_formula) }
@ -273,7 +273,7 @@ module Homebrew
end end
# Uniquify based on a string representation (or any unique identifier) # Uniquify based on a string representation (or any unique identifier)
sized_formulae.uniq { |f| f.to_s } sized_formulae.uniq(&:to_s)
} }
# Compute the total sizes (download, installed, and net) for the given formulae. # Compute the total sizes (download, installed, and net) for the given formulae.
@ -292,12 +292,10 @@ module Homebrew
total_installed_size += bottle.installed_size.to_i if bottle.installed_size total_installed_size += bottle.installed_size.to_i if bottle.installed_size
# Sum disk usage for all installed kegs of the formula. # Sum disk usage for all installed kegs of the formula.
if formula.installed_kegs.any? next if formula.installed_kegs.none?
kegs_dep_size = formula.installed_kegs.sum { |keg| keg.disk_usage.to_i } kegs_dep_size = formula.installed_kegs.sum { |keg| keg.disk_usage.to_i }
if bottle.installed_size total_net_size += bottle.installed_size.to_i - kegs_dep_size if bottle.installed_size
total_net_size += bottle.installed_size.to_i - kegs_dep_size
end
end
end end
{ download: total_download_size, { download: total_download_size,
@ -310,8 +308,8 @@ module Homebrew
if args.ask? if args.ask?
ohai "Looking for bottles..." ohai "Looking for bottles..."
sized_formulae = compute_sized_formulae(formulae_to_install) sized_formulae = compute_sized_formulae.call(formulae_to_install)
sizes = compute_total_sizes(sized_formulae, debug: args.debug?) sizes = compute_total_sizes.call(sized_formulae, debug: args.debug?)
puts "Formulae: #{sized_formulae.join(", ")}\n\n" puts "Formulae: #{sized_formulae.join(", ")}\n\n"
puts "Download Size: #{disk_usage_readable(sizes[:download])}" puts "Download Size: #{disk_usage_readable(sizes[:download])}"