Commit a24144fb authored by Fabio Pelosin's avatar Fabio Pelosin

[Git] Init submodules only after the checkout. #451

parent c4f3a5df
...@@ -30,7 +30,7 @@ module Pod ...@@ -30,7 +30,7 @@ module Pod
puts "-> Creating cache git repo (#{cache_path})" if config.verbose? puts "-> Creating cache git repo (#{cache_path})" if config.verbose?
cache_path.rmtree if cache_path.exist? cache_path.rmtree if cache_path.exist?
cache_path.mkpath cache_path.mkpath
clone(url, cache_path) git %Q|clone "#{url}" "#{cache_path}"|
end end
def prune_cache def prune_cache
...@@ -95,7 +95,6 @@ module Pod ...@@ -95,7 +95,6 @@ module Pod
def ensure_remote_branch_exists(branch) def ensure_remote_branch_exists(branch)
Dir.chdir(cache_path) { git "branch -r | grep #{branch}$" } # check for remote branch and do suffix matching ($ anchor) Dir.chdir(cache_path) { git "branch -r | grep #{branch}$" } # check for remote branch and do suffix matching ($ anchor)
return if $? == 0 return if $? == 0
raise Informative, "[!] Cache unable to find git reference `#{branch}' for `#{url}' (#{$?}).".red raise Informative, "[!] Cache unable to find git reference `#{branch}' for `#{url}' (#{$?}).".red
end end
...@@ -105,7 +104,8 @@ module Pod ...@@ -105,7 +104,8 @@ module Pod
else else
create_cache create_cache
end end
clone(clone_url, target_path) git %Q|clone "#{clone_url}" "#{target_path}"|
Dir.chdir(target_path) { git "submodule update --init" }
end end
def download_tag def download_tag
...@@ -122,27 +122,22 @@ module Pod ...@@ -122,27 +122,22 @@ module Pod
def download_commit def download_commit
ensure_ref_exists(options[:commit]) ensure_ref_exists(options[:commit])
clone(clone_url, target_path) git %Q|clone "#{clone_url}" "#{target_path}"|
Dir.chdir(target_path) do Dir.chdir(target_path) do
git "checkout -b activated-pod-commit #{options[:commit]}" git "checkout -b activated-pod-commit #{options[:commit]}"
git "submodule update --init"
end end
end end
def download_branch def download_branch
ensure_remote_branch_exists(options[:branch]) ensure_remote_branch_exists(options[:branch])
clone(clone_url, target_path) git %Q|clone "#{clone_url}" "#{target_path}"|
Dir.chdir(target_path) do Dir.chdir(target_path) do
git "remote add upstream '#{@url}'" # we need to add the original url, not the cache url git "remote add upstream '#{@url}'" # we need to add the original url, not the cache url
git "fetch -q upstream" # refresh the branches git "fetch -q upstream" # refresh the branches
git "checkout --track -b activated-pod-commit upstream/#{options[:branch]}" # create a new tracking branch git "checkout --track -b activated-pod-commit upstream/#{options[:branch]}" # create a new tracking branch
puts "Just downloaded and checked out branch: #{options[:branch]} from upstream #{clone_url}" if config.verbose?
end
end
def clone(from, to)
git "clone \"#{from}\" \"#{to}\""
Dir.chdir(to) do
git "submodule update --init" git "submodule update --init"
puts "Just downloaded and checked out branch: #{options[:branch]} from upstream #{clone_url}" if config.verbose?
end end
end end
end end
......
...@@ -177,7 +177,7 @@ module Pod ...@@ -177,7 +177,7 @@ module Pod
(pod.root + 'test.txt').should.exist? (pod.root + 'test.txt').should.exist?
end end
it "doesn't updates cache the if the ref is available" do it "doesn't update the cache if the ref is available" do
@pod.top_specification.stubs(:source).returns( @pod.top_specification.stubs(:source).returns(
:git => fixture('banana-lib'), :commit => 'fd56054' :git => fixture('banana-lib'), :commit => 'fd56054'
) )
......
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