Extract update from fetch in VCS strategies

This commit is contained in:
Jack Nagel 2014-12-06 12:29:15 -05:00
parent 3a20562d6e
commit f189454328

View File

@ -75,6 +75,9 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
def clone_repo def clone_repo
end end
def update
end
def extract_ref(specs) def extract_ref(specs)
key = REF_TYPES.find { |type| specs.key?(type) } key = REF_TYPES.find { |type| specs.key?(type) }
return key, specs[key] return key, specs[key]
@ -466,13 +469,7 @@ class GitDownloadStrategy < VCSDownloadStrategy
if @clone.exist? && repo_valid? if @clone.exist? && repo_valid?
puts "Updating #@clone" puts "Updating #@clone"
@clone.cd do update
config_repo
update_repo
checkout
reset
update_submodules if submodules?
end
elsif @clone.exist? elsif @clone.exist?
puts "Removing invalid .git repo from cache" puts "Removing invalid .git repo from cache"
clear_cache clear_cache
@ -498,6 +495,16 @@ class GitDownloadStrategy < VCSDownloadStrategy
"git" "git"
end end
def update
@clone.cd do
config_repo
update_repo
checkout
reset
update_submodules if submodules?
end
end
def shallow_clone? def shallow_clone?
@shallow && support_depth? @shallow && support_depth?
end end
@ -591,7 +598,7 @@ class CVSDownloadStrategy < VCSDownloadStrategy
if @clone.exist? && repo_valid? if @clone.exist? && repo_valid?
puts "Updating #{@clone}" puts "Updating #{@clone}"
@clone.cd { safe_system cvspath, "up" } update
elsif @clone.exist? elsif @clone.exist?
puts "Removing invalid CVS repo from cache" puts "Removing invalid CVS repo from cache"
clear_cache clear_cache
@ -628,6 +635,10 @@ class CVSDownloadStrategy < VCSDownloadStrategy
end end
end end
def update
@clone.cd { safe_system cvspath, "up" }
end
def split_url(in_url) def split_url(in_url)
parts=in_url.sub(%r[^cvs://], '').split(/:/) parts=in_url.sub(%r[^cvs://], '').split(/:/)
mod=parts.pop mod=parts.pop
@ -651,7 +662,7 @@ class MercurialDownloadStrategy < VCSDownloadStrategy
if @clone.exist? && repo_valid? if @clone.exist? && repo_valid?
puts "Updating #{@clone}" puts "Updating #{@clone}"
@clone.cd { quiet_safe_system hgpath, 'pull', '--update' } update
elsif @clone.exist? elsif @clone.exist?
puts "Removing invalid hg repo from cache" puts "Removing invalid hg repo from cache"
clear_cache clear_cache
@ -688,6 +699,10 @@ class MercurialDownloadStrategy < VCSDownloadStrategy
safe_system hgpath, "clone", url, @clone safe_system hgpath, "clone", url, @clone
end end
def update
@clone.cd { quiet_safe_system hgpath, "pull", "--update" }
end
def hgpath def hgpath
@path ||= %W[ @path ||= %W[
#{which("hg")} #{which("hg")}
@ -703,7 +718,7 @@ class BazaarDownloadStrategy < VCSDownloadStrategy
if @clone.exist? && repo_valid? if @clone.exist? && repo_valid?
puts "Updating #{@clone}" puts "Updating #{@clone}"
@clone.cd { safe_system bzrpath, 'update' } update
elsif @clone.exist? elsif @clone.exist?
puts "Removing invalid bzr repo from cache" puts "Removing invalid bzr repo from cache"
clear_cache clear_cache
@ -736,6 +751,10 @@ class BazaarDownloadStrategy < VCSDownloadStrategy
safe_system bzrpath, "checkout", "--lightweight", url, @clone safe_system bzrpath, "checkout", "--lightweight", url, @clone
end end
def update
@clone.cd { safe_system bzrpath, 'update' }
end
def bzrpath def bzrpath
@path ||= %W[ @path ||= %W[
#{which("bzr")} #{which("bzr")}
@ -750,7 +769,7 @@ class FossilDownloadStrategy < VCSDownloadStrategy
if @clone.exist? && repo_valid? if @clone.exist? && repo_valid?
puts "Updating #{@clone}" puts "Updating #{@clone}"
safe_system fossilpath, "pull", "-R", @clone update
elsif @clone.exist? elsif @clone.exist?
puts "Removing invalid fossil repo from cache" puts "Removing invalid fossil repo from cache"
clear_cache clear_cache
@ -784,6 +803,10 @@ class FossilDownloadStrategy < VCSDownloadStrategy
safe_system fossilpath, "clone", url, @clone safe_system fossilpath, "clone", url, @clone
end end
def update
safe_system fossilpath, "pull", "-R", @clone
end
def fossilpath def fossilpath
@path ||= %W[ @path ||= %W[
#{which("fossil")} #{which("fossil")}