Commit 0478e8bf authored by Ian Ynda-Hummel's avatar Ian Ynda-Hummel

Migrate existing repos when running setup.

parent 43d71e2e
require 'fileutils'
module Pod module Pod
class Command class Command
class Setup < Command class Setup < Command
...@@ -30,6 +32,8 @@ module Pod ...@@ -30,6 +32,8 @@ module Pod
set_master_repo_url set_master_repo_url
set_master_repo_branch set_master_repo_branch
update_master_repo update_master_repo
elsif old_master_repo_dir.exist?
migrate_repos
else else
add_master_repo add_master_repo
end end
...@@ -43,6 +47,21 @@ module Pod ...@@ -43,6 +47,21 @@ module Pod
# @!group Setup steps # @!group Setup steps
# Migrates any repos from the old directory structure to the new directory
# structure.
#
# @return [void]
def migrate_repos
config.repos_dir.mkpath
Dir.foreach config.old_repos_dir do |repo_dir|
source_repo_dir = config.old_repos_dir + repo_dir
target_repo_dir = config.repos_dir + repo_dir
if not repo_dir =~ /\.+/ and source_repo_dir != config.repos_dir
FileUtils.mv source_repo_dir, target_repo_dir
end
end
end
# Sets the url of the master repo according to whether it is push. # Sets the url of the master repo according to whether it is push.
# #
# @return [void] # @return [void]
...@@ -129,6 +148,12 @@ module Pod ...@@ -129,6 +148,12 @@ module Pod
def master_repo_dir def master_repo_dir
SourcesManager.master_repo_dir SourcesManager.master_repo_dir
end end
# @return [Pathname] the directory of the old master repo.
#
def old_master_repo_dir
SourcesManager.old_master_repo_dir
end
end end
end end
end end
...@@ -146,6 +146,10 @@ module Pod ...@@ -146,6 +146,10 @@ module Pod
attr_writer :repos_dir attr_writer :repos_dir
def old_repos_dir
@old_repos_dir ||= Pathname.new('~/.cocoapods').expand_path
end
# @return [Pathname] the root of the CocoaPods installation where the # @return [Pathname] the root of the CocoaPods installation where the
# Podfile is located. # Podfile is located.
# #
......
...@@ -259,6 +259,11 @@ module Pod ...@@ -259,6 +259,11 @@ module Pod
config.repos_dir + 'master' config.repos_dir + 'master'
end end
# @return [Pathname] The path of the old master repo.
def old_master_repo_dir
config.old_repos_dir + 'master'
end
# @return [Bool] Checks if the master repo is usable. # @return [Bool] Checks if the master repo is usable.
# #
# @note Note this is used to automatically setup the master repo if # @note Note this is used to automatically setup the master repo if
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment