From 0cc688f843bf8f1dacfef01c6941cd979f96d62e Mon Sep 17 00:00:00 2001 From: thibhero Date: Thu, 6 Feb 2025 12:37:19 -0500 Subject: [PATCH] resolving typecheck and final tests --- Library/Homebrew/cmd/install.rb | 43 ++++++++++++++++++--------------- Library/Homebrew/env_config.rb | 2 +- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 8a771e62f4..d03615047b 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -121,8 +121,9 @@ module Homebrew description: "Delete files that already exist in the prefix while linking.", }], [: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| options = args.pop send(*args, **options) @@ -312,35 +313,37 @@ module Homebrew bottle_size = 0 installed_size = 0 installed_formulae.each do |f| - if (bottle = f.bottle) - begin - bottle.fetch_tab(quiet: !args.debug?) - bottle_size += bottle.bottle_size if bottle.bottle_size - installed_size += bottle.installed_size if bottle.installed_size - package.push(f, f.recursive_dependencies) - unless f.deps.empty? - f.recursive_dependencies.each do |dep| - bottle = dep.to_formula.bottle - bottle.fetch_tab(quiet: !args.debug?) - bottle_size += bottle.bottle_size if bottle.bottle_size - installed_size += bottle.installed_size if bottle.installed_size - end + next unless (bottle = f.bottle) + + begin + bottle.fetch_tab(quiet: !args.debug?) + bottle_size += T.must(bottle.bottle_size) if bottle.bottle_size + installed_size += T.must(bottle.installed_size) if bottle.installed_size + package.push(f, f.recursive_dependencies) + unless f.deps.empty? + f.recursive_dependencies.each do |dep| + bottle_dep = dep.to_formula.bottle + bottle_dep.fetch_tab(quiet: !args.debug?) + bottle_size += bottle_dep.bottle_size if bottle_dep.bottle_size + installed_size += bottle_dep.installed_size if bottle_dep.installed_size end - rescue RuntimeError => e - odebug e end + rescue RuntimeError => e + odebug e end end puts "Packages : #{package.join(", ")}\n\n" puts "Bottle Size: #{disk_usage_readable(bottle_size)}" if bottle_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]" + accepted_inputs = %w[y yes] + declined_inputs = %w[n no] loop do - result = STDIN.gets.chomp.strip.downcase - if result == "y" || result == "yes" + result = $stdin.gets.chomp.strip.downcase + if accepted_inputs.include?(result) puts "Proceeding with installation..." break - elsif result == "n" + elsif declined_inputs.include?(result) return else puts "Invalid input. Please enter 'Y', 'y', or 'yes' to proceed, or 'N' to abort." diff --git a/Library/Homebrew/env_config.rb b/Library/Homebrew/env_config.rb index 4d4b8f5f79..309f86bfa1 100644 --- a/Library/Homebrew/env_config.rb +++ b/Library/Homebrew/env_config.rb @@ -48,7 +48,7 @@ module Homebrew "trying any other/default URLs.", boolean: true, }, - HOMEBREW_ASK: { + HOMEBREW_ASK: { description: "If set, pass `--ask`to all formula install commands.", boolean: true, },