Handle Tap migration in Tap#initialize.
This commit is contained in:
parent
ff8d14fe2a
commit
b109e6da5d
@ -1,18 +1,38 @@
|
||||
module CaskTapMigrationExtension
|
||||
def parse_user_repo(*args)
|
||||
user, repo = super
|
||||
module CaskTapMigration
|
||||
def initialize(user, repo)
|
||||
super
|
||||
|
||||
if user == "caskroom"
|
||||
user = "Homebrew"
|
||||
repo = "cask-#{repo}" unless repo == "cask"
|
||||
end
|
||||
return unless user == "caskroom"
|
||||
|
||||
[user, repo]
|
||||
# TODO: Remove this check after migration.
|
||||
return unless repo == "tap-migration-test"
|
||||
|
||||
new_user = "Homebrew"
|
||||
new_repo = (repo == "cask") ? repo : "cask-#{repo}"
|
||||
|
||||
old_name = name
|
||||
old_path = path
|
||||
old_remote = path.git_origin
|
||||
|
||||
super(new_user, new_repo)
|
||||
|
||||
return unless old_path.git?
|
||||
|
||||
new_name = name
|
||||
new_path = path
|
||||
new_remote = default_remote
|
||||
|
||||
ohai "Migrating Tap #{old_name} to #{new_name} …"
|
||||
|
||||
puts "Moving #{old_path} to #{new_path} …"
|
||||
path.dirname.mkpath
|
||||
FileUtils.mv old_path, new_path
|
||||
|
||||
puts "Changing remote from #{old_remote} to #{new_remote} …"
|
||||
new_path.git_origin = new_remote
|
||||
end
|
||||
end
|
||||
|
||||
class Tap
|
||||
class << self
|
||||
prepend CaskTapMigrationExtension
|
||||
end
|
||||
prepend CaskTapMigration
|
||||
end
|
||||
|
||||
@ -13,6 +13,13 @@ module GitRepositoryExtension
|
||||
end
|
||||
end
|
||||
|
||||
def git_origin=(origin)
|
||||
return unless git? && Utils.git_available?
|
||||
cd do
|
||||
Utils.popen_read("git", "remote", "set-url", "origin", origin).chuzzle
|
||||
end
|
||||
end
|
||||
|
||||
def git_head
|
||||
return unless git? && Utils.git_available?
|
||||
cd do
|
||||
|
||||
@ -12,7 +12,7 @@ class Tap
|
||||
|
||||
TAP_DIRECTORY = HOMEBREW_LIBRARY/"Taps"
|
||||
|
||||
def self.parse_user_repo(*args)
|
||||
def self.fetch(*args)
|
||||
case args.length
|
||||
when 1
|
||||
user, repo = args.first.split("/", 2)
|
||||
@ -29,13 +29,6 @@ class Tap
|
||||
user = user.capitalize if ["homebrew", "linuxbrew"].include? user
|
||||
repo = repo.strip_prefix "homebrew-"
|
||||
|
||||
[user, repo]
|
||||
end
|
||||
private_class_method :parse_user_repo
|
||||
|
||||
def self.fetch(*args)
|
||||
user, repo = parse_user_repo(*args)
|
||||
|
||||
if ["Homebrew", "Linuxbrew"].include?(user) && ["core", "homebrew"].include?(repo)
|
||||
return CoreTap.instance
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user