Skip to content

Avoid repeated Cask rename migrations during update - #24031

Merged
MikeMcQuaid merged 1 commit into
Homebrew:mainfrom
joseph1020:reduce-update-cask-loads
Sep 19, 2026
Merged

MikeMcQuaid merged 1 commit into
Homebrew:mainfrom
joseph1020:reduce-update-cask-loads

Conversation

@joseph1020

Copy link
Copy Markdown
Contributor

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run 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.

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

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.

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes sense, thanks!

@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Sep 19, 2026
Merged via the queue into Homebrew:main with commit 5fe2895 Sep 19, 2026
53 checks passed
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.

2 participants