support splitting cask versions by arch#22462
Conversation
Teach `brew bump --open-pr --casks --auto` to pass arch-specific version arguments when livecheck returns split versions for a cask with one general version. `bump-cask-pr` can then split root version and checksum stanzas, scope replacements to the matching architecture, and keep nested system conditionals manual.
|
Thanks for your pull request. This has been closed because it appears to use an incomplete or outdated pull request template. Please edit this pull request to fill in the current pull request template. This workflow will reopen this pull request automatically once the template is complete. Do not open a new pull request for this. |
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Can you explain the motivation for this change (beyond just "samford said so", what problems it solved, what approaches you considered and rejected and how you have manually tested this yourself?
|
sure thing motivation is to address the case where livecheck for auto bumped cask returns different ARM and Intel versions but the cask still has a single root version. currently I thought about trying a broader scoped change to solve more merge/split permutations across nested for implementation strategy, I considered a regex change in I landed on adding AST helpers so replacement can be scoped to root,
For targeted regression coverage, I ran the test targets for the three areas changed by this PR:
tested the top-level architecture-checksum path separately with |
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Thanks @TyceHerrman! Makes sense to me but want to have @samford take a look before merge!
There was a problem hiding this comment.
Pull request overview
This PR adds support for arch-specific cask version bumps, allowing brew bump/bump-cask-pr to split root cask versions into ARM/Intel stanzas and update scoped version/checksum values.
Changes:
- Extracts version argument generation in
brew bumpfor general ↔ arch-specific cask version transitions. - Adds AST helpers for scoped cask stanza lookup/replacement and root stanza splitting.
- Adds tests for scoped AST replacement and new cask bump rewrite behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
Library/Homebrew/dev-cmd/bump.rb |
Builds appropriate --version-* arguments for arch-specific cask bumps. |
Library/Homebrew/dev-cmd/bump-cask-pr.rb |
Splits root version/checksum stanzas and performs scoped replacements. |
Library/Homebrew/utils/ast.rb |
Adds cask AST helpers for scoped stanza detection/replacement and arch block generation. |
Library/Homebrew/test/dev-cmd/bump_spec.rb |
Adds tests for new bump argument routing. |
Library/Homebrew/test/dev-cmd/bump-cask-pr_spec.rb |
Adds end-to-end tests for version/checksum splitting and replacement. |
Library/Homebrew/test/utils/ast/cask_ast_spec.rb |
Adds tests for scoped AST stanza replacement. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def on_system_blocks(name) | ||
| body_children(cask_block.body).grep(BlockNode).select do |node| | ||
| node.method_name == name && node.receiver.nil? | ||
| end | ||
| end |
| tmp_cask = Cask::CaskLoader::FromContentLoader.new(contents) | ||
| .load(config: nil) | ||
| old_hash = tmp_cask.sha256 | ||
| next if new_hash.is_a?(String) && old_hash.to_s == new_hash |
This implements the safe root-level version split case mentioned in #21692, while preserving the manual warning for nested unsupported forms. It allows casks brew bump --open-pr -casks --auto to emit arch-specific versions when a cask's livecheck returns split versions and updates bump-cask-pr to rewrite the root version stanza into on_arm / on_intel blocks while preserving existing sha256 behavior.
brew lgtm(style, typechecking and tests) with your changes locally?agent was used to help architect and write code, but code was reviewed by me