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