Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Library/Homebrew/cmd/update_report/reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
39 changes: 39 additions & 0 deletions Library/Homebrew/test/cmd/update-report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading