From 66817c0c320c8fcf27de47923d0657c87fbf08f6 Mon Sep 17 00:00:00 2001 From: hyuraku <32809703+hyuraku@users.noreply.github.com> Date: Wed, 17 Aug 2022 22:14:20 +0900 Subject: [PATCH] repair how to show formula to be installed --- Library/Homebrew/formula_installer.rb | 4 ---- Library/Homebrew/install.rb | 32 ++++++++++++++++++++++++--- Library/Homebrew/upgrade.rb | 1 - 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 759fb247c7..aa25be9bbd 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -1185,10 +1185,6 @@ class FormulaInstaller return if self.class.fetched.include?(formula) fetch_dependencies - if dry_run? - puts "#{Formatter.identifier(formula.full_name)} would be installed" - return - end return if only_deps? diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb index 8154dd1325..382ecb8076 100644 --- a/Library/Homebrew/install.rb +++ b/Library/Homebrew/install.rb @@ -278,7 +278,7 @@ module Homebrew dry_run: false ) formula_installers = formulae_to_install.map do |f| - Migrator.migrate_if_needed(f, force: force) + Migrator.migrate_if_needed(f, force: force, dry_run: dry_run) build_options = f.build fi = FormulaInstaller.new( @@ -305,8 +305,10 @@ module Homebrew ) begin - fi.prelude - fi.fetch + unless dry_run + fi.prelude + fi.fetch + end fi rescue CannotInstallFormulaError => e ofail e.message @@ -317,6 +319,14 @@ module Homebrew end end.compact + if dry_run + formulae_name_to_install = formulae_to_install.map(&:name) + if formulae_name_to_install.present? + ohai "Would install #{formulae_name_to_install.count} #{"package".pluralize(formulae_name_to_install.count)}:" + puts formulae_name_to_install.join(" ") + end + end + formula_installers.each do |fi| install_formula(fi) Cleanup.install_formula_clean!(fi.formula) @@ -326,11 +336,27 @@ module Homebrew def install_formula(formula_installer) f = formula_installer.formula + if formula_installer.dry_run? + print_dry_run_dependencies(f, formula_installer.compute_dependencies) + return + end + upgrade = f.linked? && f.outdated? && !f.head? && !Homebrew::EnvConfig.no_install_upgrade? Upgrade.install_formula(formula_installer, upgrade: upgrade) end private_class_method :install_formula + + def print_dry_run_dependencies(formula, dependencies) + return unless dependencies.present? + + plural = "dependency".pluralize(dependencies.count) + ohai "Would install #{dependencies.count} #{plural} for #{formula.name}:" + formula_names = dependencies.map(&:first).map(&:to_formula).map(&:name) + puts formula_names.join(" ") + end + + private_class_method :print_dry_run_dependencies end end diff --git a/Library/Homebrew/upgrade.rb b/Library/Homebrew/upgrade.rb index 82b6b7a691..54e3223c18 100644 --- a/Library/Homebrew/upgrade.rb +++ b/Library/Homebrew/upgrade.rb @@ -208,7 +208,6 @@ module Homebrew # possible for the existing build to interfere with the build we are about to # do! Seriously, it happens! kegs.each(&:unlink) if kegs.present? - return if formula_installer.dry_run? formula_installer.install formula_installer.finish