Commit 4c8530b1 authored by Eloy Duran's avatar Eloy Duran

Update all spec repos in case a name is omitted.

parent 0830504b
...@@ -14,9 +14,7 @@ module Pod ...@@ -14,9 +14,7 @@ module Pod
raise ArgumentError, "needs a NAME and URL" raise ArgumentError, "needs a NAME and URL"
end end
when 'update' when 'update'
unless @name = argv[1] @name = argv[1]
raise ArgumentError, "needs a NAME"
end
when 'cd' when 'cd'
unless @name = argv[1] unless @name = argv[1]
raise ArgumentError, "needs a NAME" raise ArgumentError, "needs a NAME"
...@@ -40,7 +38,10 @@ module Pod ...@@ -40,7 +38,10 @@ module Pod
end end
def update def update
Dir.chdir(File.join(repos_dir, @name)) { git("pull") } names = @name ? [@name] : Dir.entries(repos_dir)[2..-1]
names.each do |name|
Dir.chdir(File.join(repos_dir, name)) { git("pull") }
end
end end
end end
end end
......
...@@ -16,30 +16,39 @@ describe "Pod::Command" do ...@@ -16,30 +16,39 @@ describe "Pod::Command" do
git_config('master', 'remote.origin.url').should == fixture('master-spec-repo.git') git_config('master', 'remote.origin.url').should == fixture('master-spec-repo.git')
end end
it "adds a spec-repo" do def command(*argv)
command = Pod::Command.parse('repo', 'add', 'private', fixture('master-spec-repo.git')) command = Pod::Command.parse(*argv)
def command.repos_dir; SpecHelper.tmp_repos_path; end def command.repos_dir; SpecHelper.tmp_repos_path; end
command.run command.run
command
end
it "adds a spec-repo" do
command('repo', 'add', 'private', fixture('master-spec-repo.git'))
git_config('private', 'remote.origin.url').should == fixture('master-spec-repo.git') git_config('private', 'remote.origin.url').should == fixture('master-spec-repo.git')
end end
it "updates a spec-repo" do it "updates a spec-repo" do
repo1 = Pod::Command.parse('repo', 'add', 'repo1', fixture('master-spec-repo.git')) repo1 = command('repo', 'add', 'repo1', fixture('master-spec-repo.git'))
def repo1.repos_dir; SpecHelper.tmp_repos_path; end repo2 = command('repo', 'add', 'repo2', repo1.dir)
repo1.run
repo2 = Pod::Command.parse('repo', 'add', 'repo2', repo1.dir)
def repo2.repos_dir; SpecHelper.tmp_repos_path; end
repo2.run
File.open(File.join(repo1.dir, 'README'), 'a') { |f| f << 'updated!' } File.open(File.join(repo1.dir, 'README'), 'a') { |f| f << 'updated!' }
git('repo1', 'commit -a -m "update"') git('repo1', 'commit -a -m "update"')
command = Pod::Command.parse('repo', 'update', 'repo2') command('repo', 'update', 'repo2')
def command.repos_dir; SpecHelper.tmp_repos_path; end File.read(File.join(repo2.dir, 'README')).should.include 'updated!'
command.run end
it "updates all the spec-repos" do
repo1 = command('repo', 'add', 'repo1', fixture('master-spec-repo.git'))
repo2 = command('repo', 'add', 'repo2', repo1.dir)
repo3 = command('repo', 'add', 'repo3', repo1.dir)
File.open(File.join(repo1.dir, 'README'), 'a') { |f| f << 'updated!' }
git('repo1', 'commit -a -m "update"')
command('repo', 'update')
File.read(File.join(repo2.dir, 'README')).should.include 'updated!' File.read(File.join(repo2.dir, 'README')).should.include 'updated!'
File.read(File.join(repo3.dir, 'README')).should.include 'updated!'
end end
end end
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