formula: change how #to_hash is defined for backwards compatibility

Now the output of commands like `brew info --json=` and
`brew generate-formula-api` should be the same as before along with
the additional files for the internal API. Before this commit the
hash key order had changed.
This commit is contained in:
apainintheneck 2024-02-03 13:21:32 -08:00 committed by Patrick Linnane
parent 3c503cdf56
commit 54b54b7e93
No known key found for this signature in database

View File

@ -2238,7 +2238,13 @@ class Formula
"keg_only" => keg_only?,
"keg_only_reason" => keg_only_reason&.to_hash,
"options" => [],
**dependencies_hash,
"build_dependencies" => [],
"dependencies" => [],
"test_dependencies" => [],
"recommended_dependencies" => [],
"optional_dependencies" => [],
"uses_from_macos" => [],
"uses_from_macos_bounds" => [],
"requirements" => serialized_requirements,
"conflicts_with" => conflicts.map(&:name),
"conflicts_with_reasons" => conflicts.map(&:reason),
@ -2267,6 +2273,8 @@ class Formula
{ "option" => opt.flag, "description" => opt.description }
end
hsh.merge!(dependencies_hash)
hsh["installed"] = installed_kegs.sort_by(&:version).map do |keg|
tab = Tab.for_keg keg
{
@ -2307,7 +2315,7 @@ class Formula
.transform_values(&:presence)
.compact
api_hash.merge(dep_hash)
api_hash.merge!(dep_hash)
# Exclude default values.
api_hash["revision"] = revision unless revision.zero?