refactoring and updating functions to correctly print formula to upgrade
This commit is contained in:
parent
1ba3f32026
commit
5886b51df7
@ -228,7 +228,6 @@ module Homebrew
|
||||
loop do
|
||||
result = $stdin.gets.chomp.strip.downcase
|
||||
if accepted_inputs.include?(result)
|
||||
puts "Proceeding with installation..."
|
||||
break
|
||||
elsif declined_inputs.include?(result)
|
||||
return
|
||||
@ -238,44 +237,36 @@ module Homebrew
|
||||
end
|
||||
}
|
||||
|
||||
# Build a unique list of formulae to size by including:
|
||||
# 1. The original formulae to install.
|
||||
# 2. Their outdated dependents (subject to pruning criteria).
|
||||
# 3. Optionally, any installed formula that depends on one of these and is outdated.
|
||||
compute_sized_formulae = lambda { |f, check_dep: true, upgrade: true|
|
||||
sized_formulae = f.flat_map do |formula|
|
||||
# Always include the formula itself.
|
||||
formula_list = [formula]
|
||||
|
||||
next unless upgrade
|
||||
deps = args.build_from_source? ? formula.deps.build : formula.deps.required
|
||||
# If there are dependencies, try to gather outdated, bottled ones.
|
||||
if formula.deps.any? && check_dep
|
||||
outdated_dependents = formula.recursive_dependencies do |_, dep|
|
||||
dep_formula = dep.to_formula
|
||||
next :prune if dep_formula.deps.empty?
|
||||
next :prune if !upgrade || !dep_formula.outdated?
|
||||
next :prune unless dep_formula.bottled?
|
||||
end.flatten
|
||||
if deps.any? && check_dep
|
||||
outdated_dependents = deps.map(&:to_formula).reject(&:pinned?).select do |dep|
|
||||
dep.installed_kegs.empty? || (dep.bottled? && dep.outdated?)
|
||||
end
|
||||
|
||||
# Convert each dependency to its formula.
|
||||
formula_list.concat(outdated_dependents.flat_map { |dep| Array(dep.to_formula) })
|
||||
formula_list.concat(outdated_dependents)
|
||||
end
|
||||
|
||||
formula_list
|
||||
end
|
||||
|
||||
# Add any installed formula that depends on one of the sized formulae and is outdated.
|
||||
if !Homebrew::EnvConfig.no_installed_dependents_check? && check_dep
|
||||
installed_outdated = Formula.installed.select do |installed_formula|
|
||||
if check_dep && !Homebrew::EnvConfig.no_installed_dependents_check?
|
||||
sized_formulae.concat(Formula.installed.select do |installed_formula|
|
||||
installed_formula.outdated? &&
|
||||
installed_formula.deps.any? { |dep| sized_formulae.include?(dep.to_formula) }
|
||||
end
|
||||
sized_formulae.concat(installed_outdated)
|
||||
installed_formula.deps.required.any? { |dep| sized_formulae.include?(dep.to_formula) }
|
||||
end)
|
||||
end
|
||||
|
||||
# Uniquify based on a string representation (or any unique identifier)
|
||||
sized_formulae.uniq(&:to_s)
|
||||
}
|
||||
|
||||
|
||||
# Compute the total sizes (download, installed, and net) for the given formulae.
|
||||
compute_total_sizes = lambda { |sized_formulae, debug: false|
|
||||
total_download_size = 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user