Avoid repeated Cask rename migrations during update - #24031
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?update-report currently calls migrate_cask_rename once for every reporter:
hub.reporters.each(&:migrate_cask_rename)
However, migrate_cask_rename does not use any reporter-specific state. Each invocation loads all installed casks through Cask::Caskroom.casks and runs Cask::Migrator.migrate_if_needed across the same global set.
When several taps are updated in one run, this repeats the same installed-Cask traversal once per reporter.
This change moves the global Cask rename migration to ReporterHub and invokes it once:
hub.migrate_cask_renames
Reporter-specific tap and formula migrations remain unchanged.
I noticed this while investigating repeated load-time Cask DSL warnings during brew outdated with auto-update. With three updated taps, the same installed Cask warnings were emitted repeatedly as each reporter ran the global Cask rename migration.
To reproduce:
Have multiple taps receive updates in the same brew auto-update.
Have an installed third-party cask that emits a warning while its definition is loaded.
Run:
brew outdated
Before this change, the Cask rename migration loads the installed Cask set once per updated reporter. After this change, that migration loads it once for the update-report run.
The regression test verifies that ReporterHub#migrate_cask_renames calls Cask::Caskroom.casks once and processes the returned casks once.
The test was added first and failed with:
NoMethodError:
undefined method 'migrate_cask_renames' for an instance of ReporterHub
After the implementation change it passes.
Local verification:
./bin/brew tests --only=cmd/update-report
./bin/brew style --fix --changed
./bin/brew typecheck
./bin/brew tests --online --changed
./bin/brew lgtm --online
git diff --check
All passed successfully.
AI/LLM disclosure: I used ChatGPT (GPT-5.6 Sol) to help investigate the repeated Cask loading, trace the update-report and reporter code paths, review the historical structure, and draft the regression test and PR description. I manually reviewed the changes, reproduced the failing regression test before the implementation change, confirmed it passed afterwards, ran the full update-report spec, and ran the Homebrew validation commands listed above. I will answer maintainer questions and review comments myself without AI/LLM.