mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
refactoring style to resolve the last discussions
This commit is contained in:
parent
fe06e04e28
commit
19901b5332
@ -353,32 +353,27 @@ module Homebrew
|
|||||||
dry_run: args.dry_run?,
|
dry_run: args.dry_run?,
|
||||||
)
|
)
|
||||||
|
|
||||||
if args.ask?
|
# Main block: if asking the user is enabled, show dependency and size information.
|
||||||
formulae_dependencies = Install.collect_dependencies(formulae_installer, dependants)
|
Install.ask_formulae(formulae_installer, dependants, args: args) if args.ask?
|
||||||
# Main block: if asking the user is enabled, show dependency and size information.
|
|
||||||
Install.ask_formulae(formulae_dependencies, args: args)
|
|
||||||
end
|
|
||||||
|
|
||||||
Install.install_formulae(formulae_installer,
|
Install.install_formulae(formulae_installer,
|
||||||
dry_run: args.dry_run?,
|
dry_run: args.dry_run?,
|
||||||
verbose: args.verbose?)
|
verbose: args.verbose?)
|
||||||
|
|
||||||
if dependants.present?
|
Upgrade.upgrade_dependents(
|
||||||
Upgrade.upgrade_dependents(
|
dependants, installed_formulae,
|
||||||
dependants, installed_formulae,
|
flags: args.flags_only,
|
||||||
flags: args.flags_only,
|
dry_run: args.dry_run?,
|
||||||
dry_run: args.dry_run?,
|
force_bottle: args.force_bottle?,
|
||||||
force_bottle: args.force_bottle?,
|
build_from_source_formulae: args.build_from_source_formulae,
|
||||||
build_from_source_formulae: args.build_from_source_formulae,
|
interactive: args.interactive?,
|
||||||
interactive: args.interactive?,
|
keep_tmp: args.keep_tmp?,
|
||||||
keep_tmp: args.keep_tmp?,
|
debug_symbols: args.debug_symbols?,
|
||||||
debug_symbols: args.debug_symbols?,
|
force: args.force?,
|
||||||
force: args.force?,
|
debug: args.debug?,
|
||||||
debug: args.debug?,
|
quiet: args.quiet?,
|
||||||
quiet: args.quiet?,
|
verbose: args.verbose?
|
||||||
verbose: args.verbose?
|
)
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
Cleanup.periodic_clean!(dry_run: args.dry_run?)
|
Cleanup.periodic_clean!(dry_run: args.dry_run?)
|
||||||
|
|
||||||
|
@ -169,12 +169,8 @@ module Homebrew
|
|||||||
|
|
||||||
formulae_installer = formulae_kegs.map(&:formula_installer)
|
formulae_installer = formulae_kegs.map(&:formula_installer)
|
||||||
|
|
||||||
if args.ask?
|
# Main block: if asking the user is enabled, show dependency and size information.
|
||||||
|
Install.ask_formulae(formulae_installer, dependants, args: args) if args.ask?
|
||||||
formulae_dependencies = Install.collect_dependencies(formulae_installer, dependants)
|
|
||||||
# Main block: if asking the user is enabled, show dependency and size information.
|
|
||||||
Install.ask_formulae(formulae_dependencies, args: args)
|
|
||||||
end
|
|
||||||
|
|
||||||
formulae_kegs.each do |f|
|
formulae_kegs.each do |f|
|
||||||
Homebrew::Reinstall.reinstall_formula(
|
Homebrew::Reinstall.reinstall_formula(
|
||||||
@ -194,21 +190,19 @@ module Homebrew
|
|||||||
Cleanup.install_formula_clean!(f.formula)
|
Cleanup.install_formula_clean!(f.formula)
|
||||||
end
|
end
|
||||||
|
|
||||||
if dependants.present?
|
Upgrade.upgrade_dependents(
|
||||||
Upgrade.upgrade_dependents(
|
dependants, formulae,
|
||||||
dependants, formulae,
|
flags: args.flags_only,
|
||||||
flags: args.flags_only,
|
force_bottle: args.force_bottle?,
|
||||||
force_bottle: args.force_bottle?,
|
build_from_source_formulae: args.build_from_source_formulae,
|
||||||
build_from_source_formulae: args.build_from_source_formulae,
|
interactive: args.interactive?,
|
||||||
interactive: args.interactive?,
|
keep_tmp: args.keep_tmp?,
|
||||||
keep_tmp: args.keep_tmp?,
|
debug_symbols: args.debug_symbols?,
|
||||||
debug_symbols: args.debug_symbols?,
|
force: args.force?,
|
||||||
force: args.force?,
|
debug: args.debug?,
|
||||||
debug: args.debug?,
|
quiet: args.quiet?,
|
||||||
quiet: args.quiet?,
|
verbose: args.verbose?
|
||||||
verbose: args.verbose?
|
)
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if casks.any?
|
if casks.any?
|
||||||
|
@ -252,32 +252,27 @@ module Homebrew
|
|||||||
verbose: args.verbose?,
|
verbose: args.verbose?,
|
||||||
)
|
)
|
||||||
|
|
||||||
if args.ask?
|
# Main block: if asking the user is enabled, show dependency and size information.
|
||||||
formulae_dependencies = Install.collect_dependencies(formulae_installer, dependants)
|
Install.ask_formulae(formulae_installer, dependants, args: args) if args.ask?
|
||||||
# Main block: if asking the user is enabled, show dependency and size information.
|
|
||||||
Install.ask_formulae(formulae_dependencies, args: args)
|
|
||||||
end
|
|
||||||
|
|
||||||
Upgrade.upgrade_formulae(formulae_installer,
|
Upgrade.upgrade_formulae(formulae_installer,
|
||||||
dry_run: args.dry_run?,
|
dry_run: args.dry_run?,
|
||||||
verbose: args.verbose?)
|
verbose: args.verbose?)
|
||||||
|
|
||||||
if dependants.present?
|
Upgrade.upgrade_dependents(
|
||||||
Upgrade.upgrade_dependents(
|
dependants, formulae_to_install,
|
||||||
dependants, formulae_to_install,
|
flags: args.flags_only,
|
||||||
flags: args.flags_only,
|
dry_run: args.dry_run?,
|
||||||
dry_run: args.dry_run?,
|
force_bottle: args.force_bottle?,
|
||||||
force_bottle: args.force_bottle?,
|
build_from_source_formulae: args.build_from_source_formulae,
|
||||||
build_from_source_formulae: args.build_from_source_formulae,
|
interactive: args.interactive?,
|
||||||
interactive: args.interactive?,
|
keep_tmp: args.keep_tmp?,
|
||||||
keep_tmp: args.keep_tmp?,
|
debug_symbols: args.debug_symbols?,
|
||||||
debug_symbols: args.debug_symbols?,
|
force: args.force?,
|
||||||
force: args.force?,
|
debug: args.debug?,
|
||||||
debug: args.debug?,
|
quiet: args.quiet?,
|
||||||
quiet: args.quiet?,
|
verbose: args.verbose?
|
||||||
verbose: args.verbose?
|
)
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
@ -353,19 +353,11 @@ module Homebrew
|
|||||||
puts formula_names.join(" ")
|
puts formula_names.join(" ")
|
||||||
end
|
end
|
||||||
|
|
||||||
def collect_dependencies(formulae_installer, dependants)
|
|
||||||
formulae_dependencies = formulae_installer.flat_map do |f|
|
|
||||||
[f.formula, f.compute_dependencies.flatten.filter do |c|
|
|
||||||
c.is_a? Dependency
|
|
||||||
end.flat_map(&:to_formula)]
|
|
||||||
end.flatten.uniq
|
|
||||||
formulae_dependencies.concat(dependants.upgradeable) if dependants&.upgradeable
|
|
||||||
formulae_dependencies
|
|
||||||
end
|
|
||||||
|
|
||||||
# If asking the user is enabled, show dependency and size information.
|
# If asking the user is enabled, show dependency and size information.
|
||||||
def ask_formulae(formulae, args:)
|
def ask_formulae(formulae_installer, dependants, args:)
|
||||||
return if formulae.empty?
|
return if formulae_installer.empty?
|
||||||
|
|
||||||
|
formulae = collect_dependencies(formulae_installer, dependants)
|
||||||
|
|
||||||
ohai "Looking for bottles..."
|
ohai "Looking for bottles..."
|
||||||
|
|
||||||
@ -469,6 +461,16 @@ module Homebrew
|
|||||||
installed: total_installed_size,
|
installed: total_installed_size,
|
||||||
net: total_net_size }
|
net: total_net_size }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def collect_dependencies(formulae_installer, dependants)
|
||||||
|
formulae_dependencies = formulae_installer.flat_map do |f|
|
||||||
|
[f.formula, f.compute_dependencies.flatten.filter do |c|
|
||||||
|
c.is_a? Dependency
|
||||||
|
end.flat_map(&:to_formula)]
|
||||||
|
end.flatten.uniq
|
||||||
|
formulae_dependencies.concat(dependants.upgradeable) if dependants&.upgradeable
|
||||||
|
formulae_dependencies
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -329,6 +329,8 @@ module Homebrew
|
|||||||
debug: false,
|
debug: false,
|
||||||
quiet: false,
|
quiet: false,
|
||||||
verbose: false)
|
verbose: false)
|
||||||
|
return if deps.blank?
|
||||||
|
|
||||||
upgradeable = deps.upgradeable
|
upgradeable = deps.upgradeable
|
||||||
pinned = deps.pinned
|
pinned = deps.pinned
|
||||||
skipped = deps.skipped
|
skipped = deps.skipped
|
||||||
|
Loading…
x
Reference in New Issue
Block a user