Skip to content

support splitting cask versions by arch#22462

Open
TyceHerrman wants to merge 1 commit into
Homebrew:mainfrom
TyceHerrman:bump-cask-arch-version-split
Open

support splitting cask versions by arch#22462
TyceHerrman wants to merge 1 commit into
Homebrew:mainfrom
TyceHerrman:bump-cask-arch-version-split

Conversation

@TyceHerrman
Copy link
Copy Markdown

@TyceHerrman TyceHerrman commented May 29, 2026

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.

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR.

agent was used to help architect and write code, but code was reviewed by me

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.
@github-actions
Copy link
Copy Markdown

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.

@github-actions github-actions Bot closed this May 29, 2026
@github-actions github-actions Bot reopened this May 29, 2026
@TyceHerrman TyceHerrman changed the title bump: support splitting cask versions by arch support splitting cask versions by arch May 29, 2026
Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

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?

@TyceHerrman
Copy link
Copy Markdown
Author

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 brew bump --open-pr --casks --auto identifies that the upstream versions are split, but bump-cask-pr cannot rewrite the root version into on_arm / on_intel blocks. so cask updates have to be manually resolved. ran into this recently with codex desktop app. arm version had a new release, but intel version didnt.

I thought about trying a broader scoped change to solve more merge/split permutations across nested on_macos, on_system, on_arch, existing arch blocks, and mixed checksum placement. decided to stick with this narrower update for root-level version and safe root/top-level checksum is the minimal changes needed for the issue I specifically encountered (arm and intel codex desktop version divergence)

for implementation strategy, I considered a regex change in bump-cask-pr. I avoided that because the replacement behavior could not work as desired when identical version strings appear in both arch branches.

I landed on adding AST helpers so replacement can be scoped to root, on_arm, or on_intel.

  • bump.rb passes explicit --version-arm / --version-intel arguments when a root-version cask needs to become arch-specific.
  • bump-cask-pr.rb rewrites only the supported root-level shape, then scopes replacements to the matching architecture.
  • utils/ast.rb gets cask AST helpers for replacing root stanzas with arch blocks and for replacing stanza values inside a specific architecture block.

For targeted regression coverage, I ran the test targets for the three areas changed by this PR: brew bump argument selection, bump-cask-pr cask rewriting, and the AST helpers used to keep replacements scoped to the correct architecture.

./bin/brew tests --only=dev-cmd/bump
Covers brew bump decision logic, including when it should pass --version-arm / --version-intel into bump-cask-pr.

./bin/brew tests --only=dev-cmd/bump-cask-pr
Covers the cask rewrite behavior, including splitting a root version and checksum into on_arm / on_intel blocks and preserving unsupported cases as warnings/manual paths.

./bin/brew tests --only=utils/ast/cask_ast
Covers the AST helper behavior used by the rewrite, especially root-stanza replacement and architecture-scoped stanza replacement.

tested the top-level architecture-checksum path separately with SimulateSystem.with(os: :tahoe, arch: :arm) because local homebrew ruby environment reports Hardware::CPU.type as dunno and that path depends on knowing the active architecture.

Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Thanks @TyceHerrman! Makes sense to me but want to have @samford take a look before merge!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 bump for 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.

Comment on lines +715 to +719
def on_system_blocks(name)
body_children(cask_block.body).grep(BlockNode).select do |node|
node.method_name == name && node.receiver.nil?
end
end
Comment on lines 322 to +325
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants