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
commit5f5d6ace5f9df98322499e552c06cb5462f225d2 (patch)
treeaab268c8539eea4fa0ce89fb849a14b2e34af304 /Library
parent02ad6442e771d63a365cd9502e1c994780a1b12b (diff)
downloadbrew-5f5d6ace5f9df98322499e552c06cb5462f225d2.tar.bz2
GitDownloadStrategy: only fetch from remote when necessary
When we are building from a tag, and that tag is already present in the cached repository, we don't to hit the network; everything we need already exists.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/download_strategy.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index 0ff816999..90f2fe94a 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -320,7 +320,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
puts "Updating #@clone"
Dir.chdir(@clone) do
config_repo
- fetch_repo
+ update_repo
checkout
update_submodules if submodules?
end
@@ -352,6 +352,14 @@ class GitDownloadStrategy < AbstractDownloadStrategy
private
+ def git_dir
+ @clone.join(".git")
+ end
+
+ def has_tag?(tag)
+ quiet_system @@git, '--git-dir', git_dir, 'rev-parse', '-q', '--verify', tag
+ end
+
def support_depth?
@spec != :revision and host_supports_depth?
end
@@ -361,7 +369,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
end
def repo_valid?
- quiet_system @@git, "--git-dir", "#@clone/.git", "status", "-s"
+ quiet_system @@git, "--git-dir", git_dir, "status", "-s"
end
def submodules?
@@ -392,8 +400,10 @@ class GitDownloadStrategy < AbstractDownloadStrategy
safe_system @@git, 'config', 'remote.origin.fetch', refspec
end
- def fetch_repo
- quiet_safe_system @@git, 'fetch', 'origin'
+ def update_repo
+ unless @spec == :tag && has_tag?(@ref)
+ quiet_safe_system @@git, 'fetch', 'origin'
+ end
end
def clone_repo