GitDownloadStrategy: split up submodule update and checkout
This commit is contained in:
parent
e186d9a136
commit
8b27989d11
@ -350,13 +350,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
||||
end
|
||||
# http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export
|
||||
safe_system @@git, 'checkout-index', '-a', '-f', "--prefix=#{dst}/"
|
||||
# check for 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
|
||||
checkout_submodules(dst) if submodules?
|
||||
end
|
||||
end
|
||||
|
||||
@ -374,6 +368,10 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
||||
quiet_system @@git, "--git-dir", "#@clone/.git", "status", "-s"
|
||||
end
|
||||
|
||||
def submodules?
|
||||
@clone.join(".gitmodules").exist?
|
||||
end
|
||||
|
||||
def clone_args
|
||||
args = %w{clone --no-checkout}
|
||||
args << '--depth' << '1' if support_depth?
|
||||
@ -405,6 +403,15 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
||||
def clone_repo
|
||||
safe_system @@git, *clone_args
|
||||
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
|
||||
|
||||
class CVSDownloadStrategy < AbstractDownloadStrategy
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user