Fix migrations of formulae and casks to non homebrew taps
This commit is contained in:
parent
cd65109487
commit
20fb068085
@ -458,6 +458,7 @@ module Cask
|
|||||||
|
|
||||||
loaders = Tap.select { |tap| tap.installed? && !tap.core_cask_tap? }
|
loaders = Tap.select { |tap| tap.installed? && !tap.core_cask_tap? }
|
||||||
.filter_map { |tap| super("#{tap}/#{token}", warn:) }
|
.filter_map { |tap| super("#{tap}/#{token}", warn:) }
|
||||||
|
.uniq(&:path)
|
||||||
.select { |tap| tap.path.exist? }
|
.select { |tap| tap.path.exist? }
|
||||||
|
|
||||||
case loaders.count
|
case loaders.count
|
||||||
|
@ -828,6 +828,7 @@ module Formulary
|
|||||||
|
|
||||||
loaders = Tap.select { |tap| tap.installed? && !tap.core_tap? }
|
loaders = Tap.select { |tap| tap.installed? && !tap.core_tap? }
|
||||||
.filter_map { |tap| super("#{tap}/#{name}", warn:) }
|
.filter_map { |tap| super("#{tap}/#{name}", warn:) }
|
||||||
|
.uniq(&:path)
|
||||||
.select { |tap| tap.path.exist? }
|
.select { |tap| tap.path.exist? }
|
||||||
|
|
||||||
case loaders.count
|
case loaders.count
|
||||||
|
@ -82,6 +82,41 @@ RSpec.describe Cask::CaskLoader, :cask do
|
|||||||
(old_tap.path/"tap_migrations.json").write tap_migrations.to_json
|
(old_tap.path/"tap_migrations.json").write tap_migrations.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "to a cask in an other tap" do
|
||||||
|
# Can't use local-caffeine. It is a fixture in the :core_cask_tap and would take precendence over :new_tap.
|
||||||
|
let(:token) { "some-cask" }
|
||||||
|
|
||||||
|
let(:old_tap) { Tap.fetch("homebrew", "foo") }
|
||||||
|
let(:new_tap) { Tap.fetch("homebrew", "bar") }
|
||||||
|
|
||||||
|
let(:cask_file) { new_tap.cask_dir/"#{token}.rb" }
|
||||||
|
|
||||||
|
before do
|
||||||
|
new_tap.cask_dir.mkpath
|
||||||
|
FileUtils.touch cask_file
|
||||||
|
end
|
||||||
|
|
||||||
|
# FIXME
|
||||||
|
# It would be preferable not to print a warning when installing with the short token
|
||||||
|
it "warns when loading the short token" do
|
||||||
|
expect do
|
||||||
|
described_class.for(token)
|
||||||
|
end.to output(%r{Cask #{old_tap}/#{token} was renamed to #{new_tap}/#{token}\.}).to_stderr
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not warn when loading the full token in the new tap" do
|
||||||
|
expect do
|
||||||
|
described_class.for("#{new_tap}/#{token}")
|
||||||
|
end.not_to output.to_stderr
|
||||||
|
end
|
||||||
|
|
||||||
|
it "warns when loading the full token in the old tap" do
|
||||||
|
expect do
|
||||||
|
described_class.for("#{old_tap}/#{token}")
|
||||||
|
end.to output(%r{Cask #{old_tap}/#{token} was renamed to #{new_tap}/#{token}\.}).to_stderr
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "to a formula in the default tap" do
|
context "to a formula in the default tap" do
|
||||||
let(:old_tap) { core_cask_tap }
|
let(:old_tap) { core_cask_tap }
|
||||||
let(:new_tap) { core_tap }
|
let(:new_tap) { core_tap }
|
||||||
|
@ -641,6 +641,45 @@ RSpec.describe Formulary do
|
|||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "to a third-party tap" do
|
||||||
|
let(:old_tap) { Tap.fetch("another", "foo") }
|
||||||
|
let(:new_tap) { Tap.fetch("another", "bar") }
|
||||||
|
let(:formula_file) { new_tap.formula_dir/"#{token}.rb" }
|
||||||
|
|
||||||
|
before do
|
||||||
|
new_tap.formula_dir.mkpath
|
||||||
|
FileUtils.touch formula_file
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
FileUtils.rm_rf Tap::TAP_DIRECTORY/"another"
|
||||||
|
end
|
||||||
|
|
||||||
|
# FIXME
|
||||||
|
# It would be preferable not to print a warning when installing with the short token
|
||||||
|
it "warns when loading the short token" do
|
||||||
|
expect do
|
||||||
|
described_class.loader_for(token)
|
||||||
|
end.to output(
|
||||||
|
a_string_including("Formula #{old_tap}/#{token} was renamed to #{new_tap}/#{token}.").once,
|
||||||
|
).to_stderr
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not warn when loading the full token in the new tap" do
|
||||||
|
expect do
|
||||||
|
described_class.loader_for("#{new_tap}/#{token}")
|
||||||
|
end.not_to output.to_stderr
|
||||||
|
end
|
||||||
|
|
||||||
|
it "warns when loading the full token in the old tap" do
|
||||||
|
expect do
|
||||||
|
described_class.loader_for("#{old_tap}/#{token}")
|
||||||
|
end.to output(
|
||||||
|
a_string_including("Formula #{old_tap}/#{token} was renamed to #{new_tap}/#{token}.").once,
|
||||||
|
).to_stderr
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user