Skip to content

Commit

Permalink
Update all spec repos in case a name is omitted.
Browse files Browse the repository at this point in the history
  • Loading branch information
alloy committed Aug 24, 2011
1 parent 0830504 commit 4c8530b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
9 changes: 5 additions & 4 deletions lib/cocoa_pods/command/repo.rb
Expand Up @@ -14,9 +14,7 @@ def initialize(*argv)
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"
Expand All @@ -40,7 +38,10 @@ def add
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
Expand Down
35 changes: 22 additions & 13 deletions spec/functional/command_spec.rb
Expand Up @@ -16,30 +16,39 @@ def (command.add_master_repo_command).repos_dir; SpecHelper.tmp_repos_path; end
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

0 comments on commit 4c8530b

Please sign in to comment.