Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion Library/Homebrew/dev-cmd/generate-formula-api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def run
File.write("_data/formula_canonical.json", "#{canonical_json}\n") unless args.dry_run?

OnSystem::VALID_OS_ARCH_TAGS.each do |bottle_tag|
macos_version = bottle_tag.to_macos_version if bottle_tag.macos?

aliases = {}
renames = {}
variation_formulae = all_formulae.to_h do |name, formula|
Expand All @@ -95,11 +97,31 @@ def run

sha256 = bottle_collector.specification_for(bottle_tag)&.checksum&.to_s

[name, [pkg_version.to_s, version_scheme, rebuild, sha256]]
dependencies = Set.new(formula["dependencies"])

if macos_version
uses_from_macos = formula["uses_from_macos"].zip(formula["uses_from_macos_bounds"])
dependencies += uses_from_macos.filter_map do |dep, bounds|
next if bounds.blank?

since = bounds[:since]
next if since.blank?

since_macos_version = MacOSVersion.from_symbol(since)
next if since_macos_version <= macos_version

dep
end
else
dependencies += formula["uses_from_macos"]
end

[name, [pkg_version.to_s, version_scheme, rebuild, sha256, dependencies.to_a]]
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formula stub array structure is being changed from 4 elements [pkg_version, version_scheme, rebuild, sha256] to 5 elements by adding dependencies.to_a. However, the consumer code in api/internal.rb (line 127) expects a 4-element array as indicated by the type signature T::Hash[String, [String, Integer, Integer, T.nilable(String)]], and formula_stub method (lines 43-51) only accesses indices 0-3. This will break the expected API contract. The FormulaStub class and consumer code need to be updated to handle the dependencies field, or the type signature needs to be updated to reflect the new structure.

Suggested change
[name, [pkg_version.to_s, version_scheme, rebuild, sha256, dependencies.to_a]]
[name, [pkg_version.to_s, version_scheme, rebuild, sha256]]

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fine to do in a separate PR

end

json_contents = {
formulae: variation_formulae,
casks: [],
aliases: aliases,
renames: renames,
tap_migrations: CoreTap.instance.tap_migrations,
Expand Down
Loading