Merge pull request #20051 from Homebrew/internal-api-bare-minimum

Reduce the internal formula API to contain the bare minimum data
This commit is contained in:
Rylan Polster 2025-06-06 16:45:40 +00:00 committed by GitHub
commit 1f37a11b79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 7 deletions

View File

@ -75,9 +75,7 @@ module Homebrew
Homebrew::API.merge_variations(cask, bottle_tag:)
end
unless args.dry_run?
File.write("api/internal/cask.#{bottle_tag}.json", JSON.pretty_generate(variation_casks))
end
File.write("api/internal/cask.#{bottle_tag}.json", JSON.generate(variation_casks)) unless args.dry_run?
end
end
end

View File

@ -69,12 +69,26 @@ module Homebrew
File.write("_data/formula_canonical.json", "#{canonical_json}\n") unless args.dry_run?
OnSystem::VALID_OS_ARCH_TAGS.each do |bottle_tag|
variation_formulae = all_formulae.map do |_, formula|
Homebrew::API.merge_variations(formula, bottle_tag:)
variation_formulae = all_formulae.to_h do |name, formula|
formula = Homebrew::API.merge_variations(formula, bottle_tag:)
version = Version.new(formula.dig("versions", "stable"))
pkg_version = PkgVersion.new(version, formula["revision"])
rebuild = formula.dig("bottle", "stable", "rebuild") || 0
bottle_collector = Utils::Bottles::Collector.new
formula.dig("bottle", "stable", "files")&.each do |tag, data|
tag = Utils::Bottles::Tag.from_symbol(tag)
bottle_collector.add tag, checksum: Checksum.new(data["sha256"]), cellar: :any
end
sha256 = bottle_collector.specification_for(bottle_tag)&.checksum&.to_s
[name, [pkg_version.to_s, rebuild, sha256]]
end
unless args.dry_run?
File.write("api/internal/formula.#{bottle_tag}.json", JSON.pretty_generate(variation_formulae))
File.write("api/internal/formula.#{bottle_tag}.json", JSON.generate(variation_formulae))
end
end
end

View File

@ -47,7 +47,7 @@ module Utils
return if tag_version.blank?
tags.find do |candidate|
next if candidate.arch != tag.arch
next if candidate.standardized_arch != tag.standardized_arch
candidate.to_macos_version <= tag_version
rescue MacOSVersion::Error