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
7 changes: 6 additions & 1 deletion Library/Homebrew/cask/cask_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,12 @@ def self.tap_cask_token_type(tapped_token, warn:)
end
end

opoo "Cask #{old_token} was renamed to #{new_token}." if warn && old_token && new_token
if warn && old_token && new_token
destination_exists = find_cask_in_tap(token, tap).exist? ||
(tap.core_cask_tap? && !Homebrew::EnvConfig.no_install_from_api? &&
Homebrew::API.cask_tokens.include?(token))
opoo "Cask #{old_token} was renamed to #{new_token}." if destination_exists
Comment thread
p-linnane marked this conversation as resolved.
end

[token, tap, type]
end
Expand Down
7 changes: 6 additions & 1 deletion Library/Homebrew/formulary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,12 @@ def self.tap_formula_name_type(tapped_name, warn:)
end
end

opoo "Formula #{old_name} was renamed to #{new_name}." if warn && old_name && new_name
if warn && old_name && new_name
destination_exists = find_formula_in_tap(name, tap).exist? ||
(tap.core_tap? && !Homebrew::EnvConfig.no_install_from_api? &&
Homebrew::API.formula_names.include?(name))
opoo "Formula #{old_name} was renamed to #{new_name}." if destination_exists
Comment thread
p-linnane marked this conversation as resolved.
end

[name, tap, type]
end
Expand Down
22 changes: 21 additions & 1 deletion Library/Homebrew/test/cask/cask_loader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
(old_tap.path/"tap_migrations.json").write tap_migrations.to_json
end

context "to a cask in an other tap" do
context "to a cask in another tap" do
# Can't use local-caffeine. It is a fixture in the :core_cask_tap and would take precedence over :new_tap.
let(:token) { "some-cask" }

Expand Down Expand Up @@ -149,6 +149,26 @@
end
end

context "to a formula in another tap" do
let(:token) { "some-cask" }

let(:old_tap) { Tap.fetch("homebrew", "foo") }
let(:new_tap) { Tap.fetch("homebrew", "bar") }

let(:formula_file) { new_tap.formula_dir/"#{token}.rb" }

before do
new_tap.formula_dir.mkpath
FileUtils.touch formula_file
end

it "does not warn when loading the short token" do
expect do
klass.for(token)
end.not_to output.to_stderr
end
end

context "to the default tap" do
let(:old_tap) { core_tap }
let(:new_tap) { core_cask_tap }
Expand Down
21 changes: 21 additions & 0 deletions Library/Homebrew/test/formulary_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,27 @@ def formula_json_contents(extra_items = {})
# end
end

context "to a cask in a third-party tap" do
let(:old_tap) { Tap.fetch("another", "foo") }
let(:new_tap) { Tap.fetch("another", "bar") }
let(:cask_file) { new_tap.cask_dir/"#{token}.rb" }

before do
new_tap.cask_dir.mkpath
FileUtils.touch cask_file
end

after do
FileUtils.rm_rf HOMEBREW_TAP_DIRECTORY/"another"
end

it "does not warn when loading the short token" do
expect do
klass.loader_for(token)
end.not_to output.to_stderr
end
end

context "to a third-party tap" do
let(:old_tap) { Tap.fetch("another", "foo") }
let(:new_tap) { Tap.fetch("another", "bar") }
Expand Down
Loading