aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2013-02-14 17:29:58 -0600
committerJack Nagel2013-02-14 17:29:58 -0600
commit8b27989d1122c97c3b1ff1b98e7b720376ac3964 (patch)
treebd94ee20a3ae1f93cb26bb11afc70b235b461b4d /Library
parente186d9a13637cb8bfe32e92c35c549a58c44079d (diff)
downloadbrew-8b27989d1122c97c3b1ff1b98e7b720376ac3964.tar.bz2
GitDownloadStrategy: split up submodule update and checkout
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/download_strategy.rb21
1 files changed, 14 insertions, 7 deletions
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