Commit 81bb1fb7 authored by Eloy Duran's avatar Eloy Duran

Migrate the remote of an existing master spec repo to the new remote with: $ pod setup. Closes #58.

parent 2008fc52
......@@ -27,9 +27,8 @@ Gem::Specification.new do |s|
s.executables = %w{ pod }
s.require_paths = %w{ lib }
s.post_install_message = "To speed up load time of CocoaPods consider compiling the Ruby source files:\n\n" \
" $ sudo macgem install rubygems-compile\n" \
" $ sudo macgem compile cocoapods\n\n"
s.post_install_message = "[!] If this is your first time install of CocoaPods, or if " \
"you are upgrading, first run: $ pod setup"
s.add_runtime_dependency 'xcodeproj', '~> 0.0.2'
......
......@@ -14,7 +14,10 @@ module Pod
pod repo update NAME
Updates the local clone of the spec-repo `NAME'. If `NAME' is omitted
this will update all spec-repos in `~/.cocoapods'.}
this will update all spec-repos in `~/.cocoapods'.
pod repo set-url NAME URL
Updates the remote `URL' of the spec-repo `NAME'.}
end
extend Executable
......@@ -22,12 +25,12 @@ module Pod
def initialize(argv)
case @action = argv.arguments[0]
when 'add'
unless (@name = argv[1]) && (@url = argv[2])
raise Help, "Adding a repo needs a `name' and a `url'."
when 'add', 'set-url'
unless (@name = argv.arguments[1]) && (@url = argv.arguments[2])
raise Informative, "#{@action == 'add' ? 'Adding' : 'Updating the remote of'} a repo needs a `name' and a `url'."
end
when 'update'
@name = argv[1]
@name = argv.arguments[1]
else
super
end
......@@ -38,7 +41,7 @@ module Pod
end
def run
send @action
send @action.gsub('-', '_')
end
def add
......@@ -54,6 +57,12 @@ module Pod
Dir.chdir(dir) { git("pull") }
end
end
def set_url
Dir.chdir(dir) do
git("remote set-url origin '#{@url}'")
end
end
end
end
end
......
......@@ -9,7 +9,10 @@ module Pod
Creates a directory at `~/.cocoapods' which will hold your spec-repos.
This is where it will create a clone of the public `master' spec-repo from:
https://github.com/CocoaPods/Specs}
https://github.com/CocoaPods/Specs
If the clone already exists, it will ensure that it points to the correct
remote.}
end
def initialize(argv)
......@@ -24,8 +27,16 @@ module Pod
@command ||= Repo.new(ARGV.new(['add', 'master', master_repo_url]))
end
def update_master_repo_remote_command
@command ||= Repo.new(ARGV.new(['set-url', 'master', master_repo_url]))
end
def run
add_master_repo_command.run
if (config.repos_dir + 'master').exist?
update_master_repo_remote_command.run
else
add_master_repo_command.run
end
end
end
end
......
......@@ -15,6 +15,16 @@ describe "Pod::Command" do
git_config('master', 'remote.origin.url').should == fixture('spec-repos/master').to_s
end
it "updates an existing `master' clone to point to the correct remote (migration for version 0.2.0 -> 0.3.0)" do
dir = temporary_directory + 'cocoapods'
dir.mkpath
FileUtils.cp_r(fixture('spec-repos/master').to_s, dir.to_s)
command = Pod::Command.parse('setup', '--silent')
def command.master_repo_url; 'git://some-other-remote'; end
command.run
git_config('master', 'remote.origin.url').should == 'git://some-other-remote'
end
it "adds a spec-repo" do
add_repo('private', fixture('spec-repos/master'))
git_config('private', 'remote.origin.url').should == fixture('spec-repos/master').to_s
......
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