add Tap#tap_migrations
This enables tap migration feature in per tap case, which will ultimately help core/formula separation.
This commit is contained in:
parent
a7869783ad
commit
87ecd621eb
@ -68,6 +68,12 @@ class CoreFormulaRepository < Tap
|
|||||||
FORMULA_RENAMES
|
FORMULA_RENAMES
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def tap_migrations
|
||||||
|
require "tap_migrations"
|
||||||
|
TAP_MIGRATIONS
|
||||||
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def formula_file_to_name(file)
|
def formula_file_to_name(file)
|
||||||
file.basename(".rb").to_s
|
file.basename(".rb").to_s
|
||||||
|
|||||||
@ -76,6 +76,7 @@ class Tap
|
|||||||
@alias_reverse_table = nil
|
@alias_reverse_table = nil
|
||||||
@command_files = nil
|
@command_files = nil
|
||||||
@formula_renames = nil
|
@formula_renames = nil
|
||||||
|
@tap_migrations = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# The remote path to this {Tap}.
|
# The remote path to this {Tap}.
|
||||||
@ -370,6 +371,17 @@ class Tap
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Hash with tap migrations
|
||||||
|
def tap_migrations
|
||||||
|
require "utils/json"
|
||||||
|
|
||||||
|
@tap_migrations ||= if (migration_file = path/"tap_migrations.json").file?
|
||||||
|
Utils::JSON.load(migration_file.read)
|
||||||
|
else
|
||||||
|
{}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def ==(other)
|
def ==(other)
|
||||||
other = Tap.fetch(other) if other.is_a?(String)
|
other = Tap.fetch(other) if other.is_a?(String)
|
||||||
self.class == other.class && self.name == other.name
|
self.class == other.class && self.name == other.name
|
||||||
|
|||||||
@ -20,6 +20,9 @@ class TapTest < Homebrew::TestCase
|
|||||||
(@path/"formula_renames.json").write <<-EOS.undent
|
(@path/"formula_renames.json").write <<-EOS.undent
|
||||||
{ "oldname": "foo" }
|
{ "oldname": "foo" }
|
||||||
EOS
|
EOS
|
||||||
|
(@path/"tap_migrations.json").write <<-EOS.undent
|
||||||
|
{ "removed-formula": "homebrew/foo" }
|
||||||
|
EOS
|
||||||
@cmd_file = @path/"cmd/brew-tap-cmd.rb"
|
@cmd_file = @path/"cmd/brew-tap-cmd.rb"
|
||||||
@cmd_file.parent.mkpath
|
@cmd_file.parent.mkpath
|
||||||
FileUtils.touch @cmd_file
|
FileUtils.touch @cmd_file
|
||||||
@ -93,6 +96,7 @@ class TapTest < Homebrew::TestCase
|
|||||||
assert_equal @tap.alias_table, "homebrew/foo/bar" => "homebrew/foo/foo"
|
assert_equal @tap.alias_table, "homebrew/foo/bar" => "homebrew/foo/foo"
|
||||||
assert_equal @tap.alias_reverse_table, "homebrew/foo/foo" => ["homebrew/foo/bar"]
|
assert_equal @tap.alias_reverse_table, "homebrew/foo/foo" => ["homebrew/foo/bar"]
|
||||||
assert_equal @tap.formula_renames, "oldname" => "foo"
|
assert_equal @tap.formula_renames, "oldname" => "foo"
|
||||||
|
assert_equal @tap.tap_migrations, "removed-formula" => "homebrew/foo"
|
||||||
assert_equal [@cmd_file], @tap.command_files
|
assert_equal [@cmd_file], @tap.command_files
|
||||||
assert_kind_of Hash, @tap.to_hash
|
assert_kind_of Hash, @tap.to_hash
|
||||||
assert_equal true, @tap.formula_file?(@formula_file)
|
assert_equal true, @tap.formula_file?(@formula_file)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user