s/Tap.reverse_tap_migrations_renames/Tap.tap_migration_oldnames/
This commit is contained in:
parent
e6a453a20d
commit
08442734ab
@ -87,7 +87,7 @@ module Cask
|
|||||||
sig { returns(T::Array[String]) }
|
sig { returns(T::Array[String]) }
|
||||||
def old_tokens
|
def old_tokens
|
||||||
@old_tokens ||= if (tap = self.tap)
|
@old_tokens ||= if (tap = self.tap)
|
||||||
Tap.reverse_tap_migrations_renames(tap, token) +
|
Tap.tap_migration_oldnames(tap, token) +
|
||||||
tap.cask_reverse_renames.fetch(token, [])
|
tap.cask_reverse_renames.fetch(token, [])
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
|
@ -552,7 +552,7 @@ class Formula
|
|||||||
sig { returns(T::Array[String]) }
|
sig { returns(T::Array[String]) }
|
||||||
def oldnames
|
def oldnames
|
||||||
@oldnames ||= if (tap = self.tap)
|
@oldnames ||= if (tap = self.tap)
|
||||||
Tap.reverse_tap_migrations_renames(tap, name) +
|
Tap.tap_migration_oldnames(tap, name) +
|
||||||
tap.formula_reverse_renames.fetch(name, [])
|
tap.formula_reverse_renames.fetch(name, [])
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
|
@ -867,6 +867,9 @@ class Tap
|
|||||||
sig { returns(T::Hash[String, T::Array[String]]) }
|
sig { returns(T::Hash[String, T::Array[String]]) }
|
||||||
def reverse_tap_migrations_renames
|
def reverse_tap_migrations_renames
|
||||||
@reverse_tap_migrations_renames ||= tap_migrations.each_with_object({}) do |(old_name, new_name), hash|
|
@reverse_tap_migrations_renames ||= tap_migrations.each_with_object({}) do |(old_name, new_name), hash|
|
||||||
|
# Only include renames:
|
||||||
|
# + `homebrew/cask/water-buffalo`
|
||||||
|
# - `homebrew/cask`
|
||||||
next if new_name.count("/") != 2
|
next if new_name.count("/") != 2
|
||||||
|
|
||||||
hash[new_name] ||= []
|
hash[new_name] ||= []
|
||||||
@ -874,9 +877,10 @@ class Tap
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(new_tap: Tap, name_or_token: String).returns(T::Array[String]) }
|
# The old names a formula or cask had before getting migrated to the current tap.
|
||||||
def self.reverse_tap_migrations_renames(new_tap, name_or_token)
|
sig { params(current_tap: Tap, name_or_token: String).returns(T::Array[String]) }
|
||||||
key = "#{new_tap}/#{name_or_token}"
|
def self.tap_migration_oldnames(current_tap, name_or_token)
|
||||||
|
key = "#{current_tap}/#{name_or_token}"
|
||||||
|
|
||||||
Tap.each_with_object([]) do |tap, array|
|
Tap.each_with_object([]) do |tap, array|
|
||||||
next unless (renames = tap.reverse_tap_migrations_renames[key])
|
next unless (renames = tap.reverse_tap_migrations_renames[key])
|
||||||
|
@ -33,7 +33,7 @@ RSpec.describe "Internal Tap JSON -- Formula" do
|
|||||||
.with("internal/v3/homebrew-core.jws.json")
|
.with("internal/v3/homebrew-core.jws.json")
|
||||||
.and_return([JSON.parse(internal_tap_json), false])
|
.and_return([JSON.parse(internal_tap_json), false])
|
||||||
|
|
||||||
# `Tap.reverse_tap_migrations_renames` looks for renames in every
|
# `Tap.tap_migration_oldnames` looks for renames in every
|
||||||
# tap so `CoreCaskTap.tap_migrations` gets called and tries to
|
# tap so `CoreCaskTap.tap_migrations` gets called and tries to
|
||||||
# fetch stuff from the API. This just avoids errors.
|
# fetch stuff from the API. This just avoids errors.
|
||||||
allow(Homebrew::API).to receive(:fetch_json_api_file)
|
allow(Homebrew::API).to receive(:fetch_json_api_file)
|
||||||
|
@ -586,7 +586,7 @@ RSpec.describe Tap do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".reverse_tap_migration_renames" do
|
describe ".tap_migration_oldnames" do
|
||||||
let(:cask_tap) { CoreCaskTap.instance }
|
let(:cask_tap) { CoreCaskTap.instance }
|
||||||
let(:core_tap) { CoreTap.instance }
|
let(:core_tap) { CoreTap.instance }
|
||||||
|
|
||||||
@ -597,7 +597,7 @@ RSpec.describe Tap do
|
|||||||
[cask_tap, "schism-tracker", %w[schismtracker]],
|
[cask_tap, "schism-tracker", %w[schismtracker]],
|
||||||
[cask_tap, "google-cloud-sdk", %w[app-engine-go-32 app-engine-go-64]],
|
[cask_tap, "google-cloud-sdk", %w[app-engine-go-32 app-engine-go-64]],
|
||||||
].each do |tap, name, result|
|
].each do |tap, name, result|
|
||||||
expect(described_class.reverse_tap_migrations_renames(tap, name)).to eq(result)
|
expect(described_class.tap_migration_oldnames(tap, name)).to eq(result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user