From 395b8fda73e44c09ba0d4540d1d1ccb3200597fb Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Thu, 14 Feb 2013 17:29:58 -0600 Subject: GitDownloadStrategy: split up submodule update and checkout --- Library/Homebrew/download_strategy.rb | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index c3d3e04e2..358487063 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -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 -- cgit v1.2.3