Make things private
This commit is contained in:
parent
22bfd9b230
commit
65f8420232
@ -163,6 +163,8 @@ module Homebrew
|
||||
puts all_deps
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def sorted_dependents(formulae_or_casks)
|
||||
dependents(formulae_or_casks).sort_by(&:name)
|
||||
end
|
||||
|
||||
@ -183,6 +183,8 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def fetch_resource(resource)
|
||||
puts "Resource: #{resource.name}"
|
||||
fetch_fetchable resource
|
||||
|
||||
@ -36,6 +36,8 @@ module Homebrew
|
||||
gistify_logs(args.named.to_resolved_formulae.first)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def gistify_logs(formula)
|
||||
files = load_logs(formula.logs)
|
||||
build_time = formula.logs.ctime
|
||||
|
||||
@ -39,6 +39,8 @@ module Homebrew
|
||||
exec_browser(*T.unsafe(homepages))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def name_of(formula_or_cask)
|
||||
if formula_or_cask.is_a? Formula
|
||||
"Formula #{formula_or_cask.name}"
|
||||
|
||||
@ -107,6 +107,16 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
def github_remote_path(remote, path)
|
||||
if remote =~ %r{^(?:https?://|git(?:@|://))github\.com[:/](.+)/(.+?)(?:\.git)?$}
|
||||
"https://github.com/#{Regexp.last_match(1)}/#{Regexp.last_match(2)}/blob/HEAD/#{path}"
|
||||
else
|
||||
"#{remote}/#{path}"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
sig { void }
|
||||
def print_statistics
|
||||
return unless HOMEBREW_CELLAR.exist?
|
||||
@ -230,14 +240,6 @@ module Homebrew
|
||||
puts JSON.pretty_generate(json)
|
||||
end
|
||||
|
||||
def github_remote_path(remote, path)
|
||||
if remote =~ %r{^(?:https?://|git(?:@|://))github\.com[:/](.+)/(.+?)(?:\.git)?$}
|
||||
"https://github.com/#{Regexp.last_match(1)}/#{Regexp.last_match(2)}/blob/HEAD/#{path}"
|
||||
else
|
||||
"#{remote}/#{path}"
|
||||
end
|
||||
end
|
||||
|
||||
def github_info(formula_or_cask)
|
||||
return formula_or_cask.path if formula_or_cask.tap.blank? || formula_or_cask.tap.remote.blank?
|
||||
|
||||
|
||||
@ -37,6 +37,8 @@ module Homebrew
|
||||
.each(&method(:puts))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def installed_on_request?(formula)
|
||||
Tab.for_keg(formula.any_installed_keg).installed_on_request
|
||||
end
|
||||
|
||||
@ -107,6 +107,110 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
def generate_sha256_line(tag, digest, cellar, tag_column, digest_column)
|
||||
line = "sha256 "
|
||||
tag_column += line.length
|
||||
digest_column += line.length
|
||||
if cellar.is_a?(Symbol)
|
||||
line += "cellar: :#{cellar},"
|
||||
elsif cellar_parameter_needed?(cellar)
|
||||
line += %Q(cellar: "#{cellar}",)
|
||||
end
|
||||
line += " " * (tag_column - line.length)
|
||||
line += "#{tag}:"
|
||||
line += " " * (digest_column - line.length)
|
||||
%Q(#{line}"#{digest}")
|
||||
end
|
||||
|
||||
def bottle_output(bottle, root_url_using)
|
||||
cellars = bottle.checksums.filter_map do |checksum|
|
||||
cellar = checksum["cellar"]
|
||||
next unless cellar_parameter_needed? cellar
|
||||
|
||||
case cellar
|
||||
when String
|
||||
%Q("#{cellar}")
|
||||
when Symbol
|
||||
":#{cellar}"
|
||||
end
|
||||
end
|
||||
tag_column = cellars.empty? ? 0 : "cellar: #{cellars.max_by(&:length)}, ".length
|
||||
|
||||
tags = bottle.checksums.map { |checksum| checksum["tag"] }
|
||||
# Start where the tag ends, add the max length of the tag, add two for the `: `
|
||||
digest_column = tag_column + tags.max_by(&:length).length + 2
|
||||
|
||||
sha256_lines = bottle.checksums.map do |checksum|
|
||||
generate_sha256_line(checksum["tag"], checksum["digest"], checksum["cellar"], tag_column, digest_column)
|
||||
end
|
||||
erb_binding = bottle.instance_eval { binding }
|
||||
erb_binding.local_variable_set(:sha256_lines, sha256_lines)
|
||||
erb_binding.local_variable_set(:root_url_using, root_url_using)
|
||||
erb = ERB.new BOTTLE_ERB
|
||||
erb.result(erb_binding).gsub(/^\s*$\n/, "")
|
||||
end
|
||||
|
||||
def parse_json_files(filenames)
|
||||
filenames.map do |filename|
|
||||
JSON.parse(File.read(filename))
|
||||
end
|
||||
end
|
||||
|
||||
def merge_json_files(json_files)
|
||||
json_files.reduce({}) do |hash, json_file|
|
||||
json_file.each_value do |json_hash|
|
||||
json_bottle = json_hash["bottle"]
|
||||
cellar = json_bottle.delete("cellar")
|
||||
json_bottle["tags"].each_value do |json_platform|
|
||||
json_platform["cellar"] ||= cellar
|
||||
end
|
||||
end
|
||||
hash.deep_merge(json_file)
|
||||
end
|
||||
end
|
||||
|
||||
def merge_bottle_spec(old_keys, old_bottle_spec, new_bottle_hash)
|
||||
mismatches = []
|
||||
checksums = []
|
||||
|
||||
new_values = {
|
||||
root_url: new_bottle_hash["root_url"],
|
||||
rebuild: new_bottle_hash["rebuild"],
|
||||
}
|
||||
|
||||
skip_keys = [:sha256, :cellar]
|
||||
old_keys.each do |key|
|
||||
next if skip_keys.include?(key)
|
||||
|
||||
old_value = old_bottle_spec.send(key).to_s
|
||||
new_value = new_values[key].to_s
|
||||
|
||||
next if old_value.present? && new_value == old_value
|
||||
|
||||
mismatches << "#{key}: old: #{old_value.inspect}, new: #{new_value.inspect}"
|
||||
end
|
||||
|
||||
return [mismatches, checksums] if old_keys.exclude? :sha256
|
||||
|
||||
old_bottle_spec.collector.each_tag do |tag|
|
||||
old_tag_spec = old_bottle_spec.collector.specification_for(tag)
|
||||
old_hexdigest = old_tag_spec.checksum.hexdigest
|
||||
old_cellar = old_tag_spec.cellar
|
||||
new_value = new_bottle_hash.dig("tags", tag.to_s)
|
||||
if new_value.present? && new_value["sha256"] != old_hexdigest
|
||||
mismatches << "sha256 #{tag}: old: #{old_hexdigest.inspect}, new: #{new_value["sha256"].inspect}"
|
||||
elsif new_value.present? && new_value["cellar"] != old_cellar.to_s
|
||||
mismatches << "cellar #{tag}: old: #{old_cellar.to_s.inspect}, new: #{new_value["cellar"].inspect}"
|
||||
else
|
||||
checksums << { cellar: old_cellar, tag.to_sym => old_hexdigest }
|
||||
end
|
||||
end
|
||||
|
||||
[mismatches, checksums]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def keg_contain?(string, keg, ignores, formula_and_runtime_deps_names = nil)
|
||||
@put_string_exists_header, @put_filenames = nil
|
||||
|
||||
@ -185,49 +289,6 @@ module Homebrew
|
||||
cellar.present? && default_cellars.exclude?(cellar)
|
||||
end
|
||||
|
||||
def generate_sha256_line(tag, digest, cellar, tag_column, digest_column)
|
||||
line = "sha256 "
|
||||
tag_column += line.length
|
||||
digest_column += line.length
|
||||
if cellar.is_a?(Symbol)
|
||||
line += "cellar: :#{cellar},"
|
||||
elsif cellar_parameter_needed?(cellar)
|
||||
line += %Q(cellar: "#{cellar}",)
|
||||
end
|
||||
line += " " * (tag_column - line.length)
|
||||
line += "#{tag}:"
|
||||
line += " " * (digest_column - line.length)
|
||||
%Q(#{line}"#{digest}")
|
||||
end
|
||||
|
||||
def bottle_output(bottle, root_url_using)
|
||||
cellars = bottle.checksums.filter_map do |checksum|
|
||||
cellar = checksum["cellar"]
|
||||
next unless cellar_parameter_needed? cellar
|
||||
|
||||
case cellar
|
||||
when String
|
||||
%Q("#{cellar}")
|
||||
when Symbol
|
||||
":#{cellar}"
|
||||
end
|
||||
end
|
||||
tag_column = cellars.empty? ? 0 : "cellar: #{cellars.max_by(&:length)}, ".length
|
||||
|
||||
tags = bottle.checksums.map { |checksum| checksum["tag"] }
|
||||
# Start where the tag ends, add the max length of the tag, add two for the `: `
|
||||
digest_column = tag_column + tags.max_by(&:length).length + 2
|
||||
|
||||
sha256_lines = bottle.checksums.map do |checksum|
|
||||
generate_sha256_line(checksum["tag"], checksum["digest"], checksum["cellar"], tag_column, digest_column)
|
||||
end
|
||||
erb_binding = bottle.instance_eval { binding }
|
||||
erb_binding.local_variable_set(:sha256_lines, sha256_lines)
|
||||
erb_binding.local_variable_set(:root_url_using, root_url_using)
|
||||
erb = ERB.new BOTTLE_ERB
|
||||
erb.result(erb_binding).gsub(/^\s*$\n/, "")
|
||||
end
|
||||
|
||||
def sudo_purge
|
||||
return unless ENV["HOMEBREW_BOTTLE_SUDO_PURGE"]
|
||||
|
||||
@ -600,25 +661,6 @@ module Homebrew
|
||||
json_path.write(JSON.pretty_generate(json))
|
||||
end
|
||||
|
||||
def parse_json_files(filenames)
|
||||
filenames.map do |filename|
|
||||
JSON.parse(File.read(filename))
|
||||
end
|
||||
end
|
||||
|
||||
def merge_json_files(json_files)
|
||||
json_files.reduce({}) do |hash, json_file|
|
||||
json_file.each_value do |json_hash|
|
||||
json_bottle = json_hash["bottle"]
|
||||
cellar = json_bottle.delete("cellar")
|
||||
json_bottle["tags"].each_value do |json_platform|
|
||||
json_platform["cellar"] ||= cellar
|
||||
end
|
||||
end
|
||||
hash.deep_merge(json_file)
|
||||
end
|
||||
end
|
||||
|
||||
def merge
|
||||
bottles_hash = merge_json_files(parse_json_files(args.named))
|
||||
|
||||
@ -773,46 +815,6 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
def merge_bottle_spec(old_keys, old_bottle_spec, new_bottle_hash)
|
||||
mismatches = []
|
||||
checksums = []
|
||||
|
||||
new_values = {
|
||||
root_url: new_bottle_hash["root_url"],
|
||||
rebuild: new_bottle_hash["rebuild"],
|
||||
}
|
||||
|
||||
skip_keys = [:sha256, :cellar]
|
||||
old_keys.each do |key|
|
||||
next if skip_keys.include?(key)
|
||||
|
||||
old_value = old_bottle_spec.send(key).to_s
|
||||
new_value = new_values[key].to_s
|
||||
|
||||
next if old_value.present? && new_value == old_value
|
||||
|
||||
mismatches << "#{key}: old: #{old_value.inspect}, new: #{new_value.inspect}"
|
||||
end
|
||||
|
||||
return [mismatches, checksums] if old_keys.exclude? :sha256
|
||||
|
||||
old_bottle_spec.collector.each_tag do |tag|
|
||||
old_tag_spec = old_bottle_spec.collector.specification_for(tag)
|
||||
old_hexdigest = old_tag_spec.checksum.hexdigest
|
||||
old_cellar = old_tag_spec.cellar
|
||||
new_value = new_bottle_hash.dig("tags", tag.to_s)
|
||||
if new_value.present? && new_value["sha256"] != old_hexdigest
|
||||
mismatches << "sha256 #{tag}: old: #{old_hexdigest.inspect}, new: #{new_value["sha256"].inspect}"
|
||||
elsif new_value.present? && new_value["cellar"] != old_cellar.to_s
|
||||
mismatches << "cellar #{tag}: old: #{old_cellar.to_s.inspect}, new: #{new_value["cellar"].inspect}"
|
||||
else
|
||||
checksums << { cellar: old_cellar, tag.to_sym => old_hexdigest }
|
||||
end
|
||||
end
|
||||
|
||||
[mismatches, checksums]
|
||||
end
|
||||
|
||||
def old_checksums(formula, formula_ast, bottle_hash)
|
||||
bottle_node = formula_ast.bottle_block
|
||||
return if bottle_node.nil?
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user