Only warn on rename when migration destination exists#22403
Merged
Conversation
`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).
Contributor
There was a problem hiding this comment.
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.
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 edit <name>(and any otherNamedArgs#to_pathscaller) emits two rename warnings — one for Formula, one for Cask — when only one of the two actually exists at the migration destination:NamedArgs#to_pathscalls bothFormulary.path(name)andCask::CaskLoader.path(name)speculatively to resolve a name. Both lookups walktap_formula_name_type/tap_cask_token_type, which unconditionallyopoofor any matchingtap_migrations.jsonentry — 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 inFromNameLoader.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:
brew lgtm(style, typechecking and tests) with your changes locally?Claude Code (Opus 4.7) traced the duplicate warning to both
Formulary.pathandCask::CaskLoader.pathwalkingtap_formula_name_type/tap_cask_token_typefromNamedArgs#to_paths, then drafted the destination-existence gate and the two new test contexts. I reviewed the diff, confirmed the carve-out matches the existingcore_cask_tap?precedent, and verified./bin/brew lgtmpasses locally; reproduced the original double warning and the fixed single warning against a realtap_migrations.jsonsetup.