Browse files

Migrate the remote of an existing master spec repo to the new remote …

…with: $ pod setup. Closes #58.
  • Loading branch information...
1 parent 2008fc5 commit 81bb1fb7cf927bea2d91339cdb3bc43414caf3cc @alloy alloy committed Nov 12, 2011
Showing with 40 additions and 11 deletions.
  1. +2 −3 cocoapods.gemspec
  2. +15 −6 lib/cocoapods/command/repo.rb
  3. +13 −2 lib/cocoapods/command/setup.rb
  4. +10 −0 spec/functional/command_spec.rb
View
5 cocoapods.gemspec
@@ -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'
View
21 lib/cocoapods/command/repo.rb
@@ -14,20 +14,23 @@ def self.banner
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
executable :git
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 @@ def dir
end
def run
- send @action
+ send @action.gsub('-', '_')
end
def add
@@ -54,6 +57,12 @@ def update
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
View
15 lib/cocoapods/command/setup.rb
@@ -9,7 +9,10 @@ def self.banner
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 @@ def add_master_repo_command
@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
View
10 spec/functional/command_spec.rb
@@ -15,6 +15,16 @@ def command.master_repo_url; SpecHelper.fixture('spec-repos/master'); end
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

0 comments on commit 81bb1fb

Please sign in to comment.