resolving typecheck and final tests

This commit is contained in:
thibhero 2025-02-06 12:37:19 -05:00
parent 0d2afcffe6
commit 0cc688f843
2 changed files with 24 additions and 21 deletions

View File

@ -121,8 +121,9 @@ module Homebrew
description: "Delete files that already exist in the prefix while linking.", description: "Delete files that already exist in the prefix while linking.",
}], }],
[:switch, "--ask", { [:switch, "--ask", {
description: "Ask for confirmation before downloading and installing software. Print bottles and dependencies download size and install size.", description: "Ask for confirmation before downloading and installing software. " \
}] "Print bottles and dependencies download size and install size.",
}],
].each do |args| ].each do |args|
options = args.pop options = args.pop
send(*args, **options) send(*args, **options)
@ -312,35 +313,37 @@ module Homebrew
bottle_size = 0 bottle_size = 0
installed_size = 0 installed_size = 0
installed_formulae.each do |f| installed_formulae.each do |f|
if (bottle = f.bottle) next unless (bottle = f.bottle)
begin begin
bottle.fetch_tab(quiet: !args.debug?) bottle.fetch_tab(quiet: !args.debug?)
bottle_size += bottle.bottle_size if bottle.bottle_size bottle_size += T.must(bottle.bottle_size) if bottle.bottle_size
installed_size += bottle.installed_size if bottle.installed_size installed_size += T.must(bottle.installed_size) if bottle.installed_size
package.push(f, f.recursive_dependencies) package.push(f, f.recursive_dependencies)
unless f.deps.empty? unless f.deps.empty?
f.recursive_dependencies.each do |dep| f.recursive_dependencies.each do |dep|
bottle = dep.to_formula.bottle bottle_dep = dep.to_formula.bottle
bottle.fetch_tab(quiet: !args.debug?) bottle_dep.fetch_tab(quiet: !args.debug?)
bottle_size += bottle.bottle_size if bottle.bottle_size bottle_size += bottle_dep.bottle_size if bottle_dep.bottle_size
installed_size += bottle.installed_size if bottle.installed_size installed_size += bottle_dep.installed_size if bottle_dep.installed_size
end end
end end
rescue RuntimeError => e rescue RuntimeError => e
odebug e odebug e
end end
end end
end
puts "Packages : #{package.join(", ")}\n\n" puts "Packages : #{package.join(", ")}\n\n"
puts "Bottle Size: #{disk_usage_readable(bottle_size)}" if bottle_size puts "Bottle Size: #{disk_usage_readable(bottle_size)}" if bottle_size
puts "Installed Size: #{disk_usage_readable(installed_size)}\n\n" if installed_size puts "Installed Size: #{disk_usage_readable(installed_size)}\n\n" if installed_size
ohai "Do you want to proceed with the installation? [Y/y/yes/N/n]" ohai "Do you want to proceed with the installation? [Y/y/yes/N/n]"
accepted_inputs = %w[y yes]
declined_inputs = %w[n no]
loop do loop do
result = STDIN.gets.chomp.strip.downcase result = $stdin.gets.chomp.strip.downcase
if result == "y" || result == "yes" if accepted_inputs.include?(result)
puts "Proceeding with installation..." puts "Proceeding with installation..."
break break
elsif result == "n" elsif declined_inputs.include?(result)
return return
else else
puts "Invalid input. Please enter 'Y', 'y', or 'yes' to proceed, or 'N' to abort." puts "Invalid input. Please enter 'Y', 'y', or 'yes' to proceed, or 'N' to abort."