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.
This commit is contained in:
parent
02ad6442e7
commit
5f5d6ace5f
@ -320,7 +320,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
puts "Updating #@clone"
|
puts "Updating #@clone"
|
||||||
Dir.chdir(@clone) do
|
Dir.chdir(@clone) do
|
||||||
config_repo
|
config_repo
|
||||||
fetch_repo
|
update_repo
|
||||||
checkout
|
checkout
|
||||||
update_submodules if submodules?
|
update_submodules if submodules?
|
||||||
end
|
end
|
||||||
@ -352,6 +352,14 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
|
|
||||||
private
|
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?
|
def support_depth?
|
||||||
@spec != :revision and host_supports_depth?
|
@spec != :revision and host_supports_depth?
|
||||||
end
|
end
|
||||||
@ -361,7 +369,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def repo_valid?
|
def repo_valid?
|
||||||
quiet_system @@git, "--git-dir", "#@clone/.git", "status", "-s"
|
quiet_system @@git, "--git-dir", git_dir, "status", "-s"
|
||||||
end
|
end
|
||||||
|
|
||||||
def submodules?
|
def submodules?
|
||||||
@ -392,8 +400,10 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
safe_system @@git, 'config', 'remote.origin.fetch', refspec
|
safe_system @@git, 'config', 'remote.origin.fetch', refspec
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_repo
|
def update_repo
|
||||||
quiet_safe_system @@git, 'fetch', 'origin'
|
unless @spec == :tag && has_tag?(@ref)
|
||||||
|
quiet_safe_system @@git, 'fetch', 'origin'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def clone_repo
|
def clone_repo
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user