Commit dcd85e72 authored by Fabio Pelosin's avatar Fabio Pelosin

[Repo] Allow to specify a branch for new repos.

parent 319f8b9b
...@@ -6,7 +6,7 @@ module Pod ...@@ -6,7 +6,7 @@ module Pod
def self.banner def self.banner
%{Managing spec-repos: %{Managing spec-repos:
$ pod repo add NAME URL $ pod repo add NAME URL [BRANCH]
Clones `URL' in the local spec-repos directory at `~/.cocoapods'. The Clones `URL' in the local spec-repos directory at `~/.cocoapods'. The
remote can later be referred to by `NAME'. remote can later be referred to by `NAME'.
...@@ -26,6 +26,7 @@ module Pod ...@@ -26,6 +26,7 @@ module Pod
unless (@name = argv.arguments[1]) && (@url = argv.arguments[2]) 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'." raise Informative, "#{@action == 'add' ? 'Adding' : 'Updating the remote of'} a repo needs a `name' and a `url'."
end end
@branch = argv.arguments[3]
when 'update' when 'update'
@name = argv.arguments[1] @name = argv.arguments[1]
else else
...@@ -45,6 +46,7 @@ module Pod ...@@ -45,6 +46,7 @@ module Pod
puts "Cloning spec repo `#{@name}' from `#{@url}'" unless config.silent? puts "Cloning spec repo `#{@name}' from `#{@url}'" unless config.silent?
config.repos_dir.mkpath config.repos_dir.mkpath
Dir.chdir(config.repos_dir) { git("clone '#{@url}' #{@name}") } Dir.chdir(config.repos_dir) { git("clone '#{@url}' #{@name}") }
Dir.chdir(dir) { git("checkout #{@branch}") } if @branch
check_versions(dir) check_versions(dir)
end end
......
...@@ -21,6 +21,12 @@ describe "Pod::Command::Repo" do ...@@ -21,6 +21,12 @@ describe "Pod::Command::Repo" do
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
end end
it "adds a spec-repo with on a specified branch" do
repo = command( 'repo' ,'add', 'new', fixture('spec-repos/master'), '0.6')
repo.run
Dir.chdir(repo.dir) { `git symbolic-ref HEAD` }.should.include? '0.6'
end
it "updates a spec-repo" do it "updates a spec-repo" do
repo1 = add_repo('repo1', fixture('spec-repos/master')) repo1 = add_repo('repo1', fixture('spec-repos/master'))
repo2 = add_repo('repo2', repo1.dir) repo2 = add_repo('repo2', repo1.dir)
......
...@@ -30,7 +30,10 @@ module SpecHelper ...@@ -30,7 +30,10 @@ module SpecHelper
def add_repo(name, from) def add_repo(name, from)
command = command('repo', 'add', name, from) command = command('repo', 'add', name, from)
command.run command.run
Dir.chdir(command.dir) { `git checkout -b test >/dev/null 2>&1` } Dir.chdir(command.dir) do
`git checkout -b test >/dev/null 2>&1`
`git branch --set-upstream test origin/test >/dev/null 2>&1`
end
command command
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