Skip to content

Commit

Permalink
Merge pull request #17201 from Homebrew/fix-internal-formula-json-v3-…
Browse files Browse the repository at this point in the history
…frozen-hash-bug

Fix internal formula json v3 frozen hash parsing bug
  • Loading branch information
MikeMcQuaid authored May 2, 2024
2 parents e60e035 + 37cbfc4 commit bd72ec8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Library/Homebrew/extend/cachable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ def cache
@cache ||= T.let({}, T.nilable(T::Hash[T.untyped, T.untyped]))
end

# NOTE: We overwrite here instead of using `Hash#clear` to handle frozen hashes.
sig { void }
def clear_cache
cache.clear
overwrite_cache!({})
end

private
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/formulary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def self.load_formula_from_api(name, flags:)
end

if info&.key?("uses_from_macos")
bounds = info["uses_from_macos"] || {}
bounds = info["uses_from_macos"].dup || {}
bounds.deep_transform_keys!(&:to_sym)
bounds.deep_transform_values!(&:to_sym)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

allow(Homebrew::API).to receive(:fetch_json_api_file)
.with("internal/v3/homebrew-core.jws.json")
.and_return([JSON.parse(internal_tap_json), false])
.and_return([JSON.parse(internal_tap_json, freeze: true), false])

# `Tap.tap_migration_oldnames` looks for renames in every
# tap so `CoreCaskTap.tap_migrations` gets called and tries to
Expand Down

0 comments on commit bd72ec8

Please sign in to comment.