Skip to content

Only warn on rename when migration destination exists#22403

Merged
MikeMcQuaid merged 1 commit into
mainfrom
rename-warning-destination-exists
May 24, 2026
Merged

Only warn on rename when migration destination exists#22403
MikeMcQuaid merged 1 commit into
mainfrom
rename-warning-destination-exists

Conversation

@p-linnane
Copy link
Copy Markdown
Member

brew edit <name> (and any other NamedArgs#to_paths caller) emits two rename warnings — one for Formula, one for Cask — when only one of the two actually exists at the migration destination:

Warning: Formula p-linnane/tap/pinprick was renamed to starhaven-io/tap/pinprick.
Warning: Cask p-linnane/tap/pinprick was renamed to starhaven-io/tap/pinprick.
Editing /opt/homebrew/Library/Taps/starhaven-io/homebrew-tap/Casks/pinprick.rb

NamedArgs#to_paths calls both Formulary.path(name) and Cask::CaskLoader.path(name) speculatively to resolve a name. Both lookups walk tap_formula_name_type / tap_cask_token_type, which unconditionally opoo for any matching tap_migrations.json entry — including when the migrated formula (or cask) does not exist at the destination tap.

This generalises the existing !(type == :migration && migrated_tap.core_cask_tap?) carve-out in FromNameLoader.try_new (and its cask twin) to all cross-type migrations between any taps: only warn when the migrated file actually exists at the destination (or, for the core tap, is published via the API).

After:

Warning: Cask p-linnane/tap/pinprick was renamed to starhaven-io/tap/pinprick.
Editing /opt/homebrew/Library/Taps/starhaven-io/homebrew-tap/Casks/pinprick.rb

  • 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.

Claude Code (Opus 4.7) traced the duplicate warning to both Formulary.path and Cask::CaskLoader.path walking tap_formula_name_type/tap_cask_token_type from NamedArgs#to_paths, then drafted the destination-existence gate and the two new test contexts. I reviewed the diff, confirmed the carve-out matches the existing core_cask_tap? precedent, and verified ./bin/brew lgtm passes locally; reproduced the original double warning and the fixed single warning against a real tap_migrations.json setup.


`NamedArgs#to_paths` calls both `Formulary.path` and
`Cask::CaskLoader.path` speculatively to resolve a name. Both walk
`tap_formula_name_type` / `tap_cask_token_type`, which unconditionally
warn for any matching `tap_migrations.json` entry — including when the
migrated formula (or cask) does not exist at the destination tap.

This generalises the existing `core_cask_tap?` carve-out in
`FromNameLoader.try_new` to all cross-type migrations between any taps:
only warn when the migrated file actually exists at the destination
(or, for the core tap, is published via the API).
Copilot AI review requested due to automatic review settings May 24, 2026 03:04
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 updates Homebrew’s tap migration warning behavior so rename/migration warnings are only emitted when the migrated destination actually exists for the relevant type (formula vs cask), avoiding duplicate/incorrect warnings from speculative lookups (e.g., NamedArgs#to_paths calling both formula and cask resolution).

Changes:

  • Gate formula migration/rename warnings on destination existence (filesystem, or API-published for core tap).
  • Gate cask migration/rename warnings on destination existence (filesystem, or API-published for core cask tap).
  • Add/adjust specs covering cross-type migrations (formula→cask and cask→formula) and fix a wording typo in a spec context.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
Library/Homebrew/formulary.rb Only emits formula migration/rename warnings when the migrated formula destination exists (or is available via the API for core).
Library/Homebrew/cask/cask_loader.rb Only emits cask migration/rename warnings when the migrated cask destination exists (or is available via the API for core cask).
Library/Homebrew/test/formulary_spec.rb Adds coverage for “formula migration points to a cask-only destination tap” (no warning expected).
Library/Homebrew/test/cask/cask_loader_spec.rb Adds coverage for “cask migration points to a formula-only destination tap” (no warning expected) and fixes a context typo.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/formulary.rb
Comment thread Library/Homebrew/cask/cask_loader.rb
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!

@MikeMcQuaid MikeMcQuaid enabled auto-merge May 24, 2026 11:46
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue May 24, 2026
Merged via the queue into main with commit 4d7be53 May 24, 2026
59 of 61 checks passed
@MikeMcQuaid MikeMcQuaid deleted the rename-warning-destination-exists branch May 24, 2026 12:10
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