GitDownloadStrategy: split up submodule update and checkout

This commit is contained in:
Jack Nagel 2013-02-14 17:29:58 -06:00
parent e186d9a136
commit 8b27989d11

View File

@ -350,13 +350,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
end end
# http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export # http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export
safe_system @@git, 'checkout-index', '-a', '-f', "--prefix=#{dst}/" safe_system @@git, 'checkout-index', '-a', '-f', "--prefix=#{dst}/"
# check for submodules checkout_submodules(dst) if submodules?
if File.exist?('.gitmodules')
safe_system @@git, 'submodule', 'init'
safe_system @@git, 'submodule', 'update'
sub_cmd = "#{@@git} checkout-index -a -f \"--prefix=#{dst}/$path/\""
safe_system @@git, 'submodule', '--quiet', 'foreach', '--recursive', sub_cmd
end
end end
end end
@ -374,6 +368,10 @@ class GitDownloadStrategy < AbstractDownloadStrategy
quiet_system @@git, "--git-dir", "#@clone/.git", "status", "-s" quiet_system @@git, "--git-dir", "#@clone/.git", "status", "-s"
end end
def submodules?
@clone.join(".gitmodules").exist?
end
def clone_args def clone_args
args = %w{clone --no-checkout} args = %w{clone --no-checkout}
args << '--depth' << '1' if support_depth? args << '--depth' << '1' if support_depth?
@ -405,6 +403,15 @@ class GitDownloadStrategy < AbstractDownloadStrategy
def clone_repo def clone_repo
safe_system @@git, *clone_args safe_system @@git, *clone_args
end end
def update_submodules
safe_system @@git, 'submodule', 'update', '--init'
end
def checkout_submodules(dst)
sub_cmd = %W{#@@git checkout-index -a -f --prefix=#{dst}/$path/}
safe_system @@git, 'submodule', '--quiet', 'foreach', '--recursive', *sub_cmd
end
end end
class CVSDownloadStrategy < AbstractDownloadStrategy class CVSDownloadStrategy < AbstractDownloadStrategy