repair how to show formula to be installed

This commit is contained in:
hyuraku 2022-08-17 22:14:20 +09:00
parent 8a7f445d1f
commit 66817c0c32
3 changed files with 29 additions and 8 deletions

View File

@ -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?

View File

@ -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

View File

@ -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