Add compatibility layer to convert caskroom/* to homebrew/cask(-*).

This commit is contained in:
Markus Reiter 2018-05-15 14:56:28 +02:00
parent 5e773353fa
commit ff8d14fe2a
3 changed files with 27 additions and 1 deletions

View File

@ -9,3 +9,4 @@ require "compat/extend/string"
require "compat/gpg"
require "compat/dependable"
require "compat/os/mac"
require "compat/tap"

View File

@ -0,0 +1,18 @@
module CaskTapMigrationExtension
def parse_user_repo(*args)
user, repo = super
if user == "caskroom"
user = "Homebrew"
repo = "cask-#{repo}" unless repo == "cask"
end
[user, repo]
end
end
class Tap
class << self
prepend CaskTapMigrationExtension
end
end

View File

@ -12,7 +12,7 @@ class Tap
TAP_DIRECTORY = HOMEBREW_LIBRARY/"Taps"
def self.fetch(*args)
def self.parse_user_repo(*args)
case args.length
when 1
user, repo = args.first.split("/", 2)
@ -29,6 +29,13 @@ 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