Conversation
There was a problem hiding this comment.
Pull request overview
This pull request updates the internal cask API to serialize CaskStruct instances, following the same pattern established for formulae in PR #21456. The changes extract utility methods from FormulaStruct to the Utils module so they can be shared with CaskStruct, move the cask struct generation logic into a dedicated module, and implement serialization/deserialization methods for CaskStruct.
Changes:
- Refactored deep symbol stringify/unstringify and compact_blank methods from
FormulaStructtoUtilsmodule - Added serialize/deserialize methods to
CaskStructwith artifact handling - Extracted
generate_cask_struct_hashfromAPI::Caskinto newCaskStructGeneratormodule - Updated internal cask API generation to serialize cask structs before writing to JSON
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| Library/Homebrew/utils.rb | Adds deep_stringify_symbols, deep_unstringify_symbols, and deep_compact_blank utility methods moved from FormulaStruct |
| Library/Homebrew/test/utils_spec.rb | Moves tests for the utility methods from formula_struct_spec.rb to utils_spec.rb |
| Library/Homebrew/api/formula_struct.rb | Removes utility methods that were moved to Utils and updates references to use Utils module |
| Library/Homebrew/test/api/formula_struct_spec.rb | Removes tests that were moved to utils_spec.rb |
| Library/Homebrew/api/cask_struct.rb | Adds serialize, deserialize, and deserialize_artifact_args methods for CaskStruct serialization |
| Library/Homebrew/api/cask/cask_struct_generator.rb | New module containing generate_cask_struct_hash method moved from API::Cask |
| Library/Homebrew/api/cask.rb | Removes generate_cask_struct_hash method and adds require for CaskStructGenerator |
| Library/Homebrew/cask/cask_loader.rb | Updates reference to use CaskStructGenerator module |
| Library/Homebrew/dev-cmd/generate-cask-api.rb | Updates to serialize CaskStruct instances and adds tap_git_head to JSON output |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
65dbc7a to
9021f49
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9021f49 to
a68725a
Compare
|
Okay, finally had the time to overhaul this. It's split up into three commits, and I've tested this by running the following: Cask::Cask.all.reject do |cask|
original_struct = Homebrew::API::Cask::CaskStructGenerator.generate_cask_struct_hash(cask.to_hash_with_variations)
original_json = original_struct.serialize
new_struct = Homebrew::API::CaskStruct.deserialize(original_json)
new_json = new_struct.serialize
new_struct == original_struct && new_json == original_json
end.countThis returns 0, indicating that the serialization/deserialization seems to work as expected. I think this is ready to go, but it may be best to wait until after 5.1 is released, not sure what the timeline for that is. |
Follow-up to #21456
This PR updates the
/api/internal/cask.TAG.jsonAPI to contain serialized cask structs, like we did with formulae.