From dcffb26f699a7893f1d2b84e4771a44e7e970095 Mon Sep 17 00:00:00 2001 From: Patrick Linnane Date: Wed, 14 Oct 2026 16:45:01 -0700 Subject: [PATCH] Use full names for tap migration targets - `user/tap/name` targets in `tap_migrations.json` were reduced to the bare name, which `Homebrew::Trust.trusted?` never accepts, so these formula/cask migrations never ran automatically and suggested a `brew trust` command that rejects bare names. - Keeping the full name also lets third-party cask targets match `Tap#cask_tokens`, which lists full names. Signed-off-by: Patrick Linnane --- .../Homebrew/cmd/update_report/reporter.rb | 4 +- .../Homebrew/test/cmd/update-report_spec.rb | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/update_report/reporter.rb b/Library/Homebrew/cmd/update_report/reporter.rb index 68497bc33cc5d..3e4e72e2c6384 100644 --- a/Library/Homebrew/cmd/update_report/reporter.rb +++ b/Library/Homebrew/cmd/update_report/reporter.rb @@ -229,9 +229,9 @@ def migrate_tap_migration migrated_tap_name = Utils.tap_from_full_name(migration_target) new_name = if migrated_tap_name - new_full_name = Utils.name_from_full_name(migration_target) + new_full_name = migration_target new_tap_name = migrated_tap_name - new_full_name + Utils.name_from_full_name(migration_target) elsif migration_target.include?("/") new_tap_name = migration_target new_full_name = "#{new_tap_name}/#{name}" diff --git a/Library/Homebrew/test/cmd/update-report_spec.rb b/Library/Homebrew/test/cmd/update-report_spec.rb index 93252d963e31d..21b6eeb6fe80d 100644 --- a/Library/Homebrew/test/cmd/update-report_spec.rb +++ b/Library/Homebrew/test/cmd/update-report_spec.rb @@ -671,6 +671,45 @@ def perform_update(fixture_name = "") end end + describe "#migrate_tap_migration" do + let(:tap) { Tap.fetch("foo", "bar") } + + before do + tap.path.mkpath + allow(reporter).to receive(:system).and_return(true) + end + + after do + FileUtils.rm_r(tap.path.parent) + end + + it "installs a formula's renamed cask by its full name" do + (tap.path/"tap_migrations.json").write '{ "old-formula": "homebrew/cask/new-cask" }' + (CoreCaskTap.instance.path/"Casks").mkpath + (HOMEBREW_PREFIX/"Caskroom").mkpath + (HOMEBREW_CELLAR/"old-formula/1.0").mkpath + tab = Tab.empty + tab.tabfile = HOMEBREW_CELLAR/"old-formula/1.0/INSTALL_RECEIPT.json" + tab.tap = tap + tab.write + allow(reporter).to receive(:report).and_return({ D: [], DC: [], T: ["foo/bar/old-formula"] }) + + expect(reporter).to receive(:system) + .with(HOMEBREW_BREW_FILE.to_s, "install", "--cask", "homebrew/cask/new-cask") + reporter.migrate_tap_migration + end + + it "installs a cask's renamed formula by its full name" do + (tap.path/"tap_migrations.json").write '{ "old-cask": "homebrew/core/new-formula" }' + (HOMEBREW_PREFIX/"Caskroom/old-cask").mkpath + allow(reporter).to receive(:report).and_return({ D: [], DC: ["foo/bar/old-cask"], T: [] }) + + expect(reporter).to receive(:system) + .with(HOMEBREW_BREW_FILE.to_s, "install", "--overwrite", "homebrew/core/new-formula") + reporter.migrate_tap_migration + end + end + describe "#diff" do context "when using the API" do subject(:reporter) do