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