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
|
loop do
|
||||||
result = $stdin.gets.chomp.strip.downcase
|
result = $stdin.gets.chomp.strip.downcase
|
||||||
if accepted_inputs.include?(result)
|
if accepted_inputs.include?(result)
|
||||||
puts "Proceeding with installation..."
|
|
||||||
break
|
break
|
||||||
elsif declined_inputs.include?(result)
|
elsif declined_inputs.include?(result)
|
||||||
return
|
return
|
||||||
@ -238,44 +237,36 @@ module Homebrew
|
|||||||
end
|
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|
|
compute_sized_formulae = lambda { |f, check_dep: true, upgrade: true|
|
||||||
sized_formulae = f.flat_map do |formula|
|
sized_formulae = f.flat_map do |formula|
|
||||||
# Always include the formula itself.
|
# Always include the formula itself.
|
||||||
formula_list = [formula]
|
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 there are dependencies, try to gather outdated, bottled ones.
|
||||||
if formula.deps.any? && check_dep
|
if deps.any? && check_dep
|
||||||
outdated_dependents = formula.recursive_dependencies do |_, dep|
|
outdated_dependents = deps.map(&:to_formula).reject(&:pinned?).select do |dep|
|
||||||
dep_formula = dep.to_formula
|
dep.installed_kegs.empty? || (dep.bottled? && dep.outdated?)
|
||||||
next :prune if dep_formula.deps.empty?
|
end
|
||||||
next :prune if !upgrade || !dep_formula.outdated?
|
|
||||||
next :prune unless dep_formula.bottled?
|
|
||||||
end.flatten
|
|
||||||
|
|
||||||
# Convert each dependency to its formula.
|
formula_list.concat(outdated_dependents)
|
||||||
formula_list.concat(outdated_dependents.flat_map { |dep| Array(dep.to_formula) })
|
|
||||||
end
|
end
|
||||||
|
|
||||||
formula_list
|
formula_list
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add any installed formula that depends on one of the sized formulae and is outdated.
|
# Add any installed formula that depends on one of the sized formulae and is outdated.
|
||||||
if !Homebrew::EnvConfig.no_installed_dependents_check? && check_dep
|
if check_dep && !Homebrew::EnvConfig.no_installed_dependents_check?
|
||||||
installed_outdated = Formula.installed.select do |installed_formula|
|
sized_formulae.concat(Formula.installed.select do |installed_formula|
|
||||||
installed_formula.outdated? &&
|
installed_formula.outdated? &&
|
||||||
installed_formula.deps.any? { |dep| sized_formulae.include?(dep.to_formula) }
|
installed_formula.deps.required.any? { |dep| sized_formulae.include?(dep.to_formula) }
|
||||||
end
|
end)
|
||||||
sized_formulae.concat(installed_outdated)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Uniquify based on a string representation (or any unique identifier)
|
|
||||||
sized_formulae.uniq(&:to_s)
|
sized_formulae.uniq(&:to_s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Compute the total sizes (download, installed, and net) for the given formulae.
|
# Compute the total sizes (download, installed, and net) for the given formulae.
|
||||||
compute_total_sizes = lambda { |sized_formulae, debug: false|
|
compute_total_sizes = lambda { |sized_formulae, debug: false|
|
||||||
total_download_size = 0
|
total_download_size = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user