Move fetch implementation into VCS strategy superclass
This commit is contained in:
parent
4026e035ad
commit
5afa11ecab
@ -46,6 +46,21 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
|
|||||||
@clone = HOMEBREW_CACHE.join(cache_filename)
|
@clone = HOMEBREW_CACHE.join(cache_filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fetch
|
||||||
|
ohai "Cloning #{@url}"
|
||||||
|
|
||||||
|
if cached_location.exist? && repo_valid?
|
||||||
|
puts "Updating #{cached_location}"
|
||||||
|
update
|
||||||
|
elsif cached_location.exist?
|
||||||
|
puts "Removing invalid repository from cache"
|
||||||
|
clear_cache
|
||||||
|
clone_repo
|
||||||
|
else
|
||||||
|
clone_repo
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def cached_location
|
def cached_location
|
||||||
@clone
|
@clone
|
||||||
end
|
end
|
||||||
@ -372,15 +387,11 @@ class SubversionDownloadStrategy < VCSDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fetch
|
def fetch
|
||||||
ohai "Checking out #{@url}"
|
clear_cache unless @url.chomp("/") == repo_url or quiet_system "svn", "switch", @url, @clone
|
||||||
|
super
|
||||||
clear_cache unless @url.chomp("/") == repo_url or quiet_system 'svn', 'switch', @url, @clone
|
|
||||||
|
|
||||||
if @clone.exist? and not repo_valid?
|
|
||||||
puts "Removing invalid SVN repo from cache"
|
|
||||||
clear_cache
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clone_repo
|
||||||
case @ref_type
|
case @ref_type
|
||||||
when :revision
|
when :revision
|
||||||
fetch_repo @clone, @url, @ref
|
fetch_repo @clone, @url, @ref
|
||||||
@ -396,6 +407,7 @@ class SubversionDownloadStrategy < VCSDownloadStrategy
|
|||||||
fetch_repo @clone, @url
|
fetch_repo @clone, @url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
alias_method :update, :clone_repo
|
||||||
|
|
||||||
def stage
|
def stage
|
||||||
quiet_safe_system 'svn', 'export', '--force', @clone, Dir.pwd
|
quiet_safe_system 'svn', 'export', '--force', @clone, Dir.pwd
|
||||||
@ -468,21 +480,6 @@ class GitDownloadStrategy < VCSDownloadStrategy
|
|||||||
@shallow = resource.specs.fetch(:shallow) { true }
|
@shallow = resource.specs.fetch(:shallow) { true }
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch
|
|
||||||
ohai "Cloning #@url"
|
|
||||||
|
|
||||||
if @clone.exist? && repo_valid?
|
|
||||||
puts "Updating #@clone"
|
|
||||||
update
|
|
||||||
elsif @clone.exist?
|
|
||||||
puts "Removing invalid .git repo from cache"
|
|
||||||
clear_cache
|
|
||||||
clone_repo
|
|
||||||
else
|
|
||||||
clone_repo
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def stage
|
def stage
|
||||||
dst = Dir.getwd
|
dst = Dir.getwd
|
||||||
@clone.cd do
|
@clone.cd do
|
||||||
@ -597,21 +594,6 @@ class GitDownloadStrategy < VCSDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
class CVSDownloadStrategy < VCSDownloadStrategy
|
class CVSDownloadStrategy < VCSDownloadStrategy
|
||||||
def fetch
|
|
||||||
ohai "Checking out #{@url}"
|
|
||||||
|
|
||||||
if @clone.exist? && repo_valid?
|
|
||||||
puts "Updating #{@clone}"
|
|
||||||
update
|
|
||||||
elsif @clone.exist?
|
|
||||||
puts "Removing invalid CVS repo from cache"
|
|
||||||
clear_cache
|
|
||||||
clone_repo
|
|
||||||
else
|
|
||||||
clone_repo
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def stage
|
def stage
|
||||||
FileUtils.cp_r Dir[@clone+"{.}"], Dir.pwd
|
FileUtils.cp_r Dir[@clone+"{.}"], Dir.pwd
|
||||||
end
|
end
|
||||||
@ -661,21 +643,6 @@ class CVSDownloadStrategy < VCSDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
class MercurialDownloadStrategy < VCSDownloadStrategy
|
class MercurialDownloadStrategy < VCSDownloadStrategy
|
||||||
def fetch
|
|
||||||
ohai "Cloning #{@url}"
|
|
||||||
|
|
||||||
if @clone.exist? && repo_valid?
|
|
||||||
puts "Updating #{@clone}"
|
|
||||||
update
|
|
||||||
elsif @clone.exist?
|
|
||||||
puts "Removing invalid hg repo from cache"
|
|
||||||
clear_cache
|
|
||||||
clone_repo
|
|
||||||
else
|
|
||||||
clone_repo
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def stage
|
def stage
|
||||||
dst = Dir.getwd
|
dst = Dir.getwd
|
||||||
@clone.cd do
|
@clone.cd do
|
||||||
@ -717,21 +684,6 @@ class MercurialDownloadStrategy < VCSDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
class BazaarDownloadStrategy < VCSDownloadStrategy
|
class BazaarDownloadStrategy < VCSDownloadStrategy
|
||||||
def fetch
|
|
||||||
ohai "Cloning #{@url}"
|
|
||||||
|
|
||||||
if @clone.exist? && repo_valid?
|
|
||||||
puts "Updating #{@clone}"
|
|
||||||
update
|
|
||||||
elsif @clone.exist?
|
|
||||||
puts "Removing invalid bzr repo from cache"
|
|
||||||
clear_cache
|
|
||||||
clone_repo
|
|
||||||
else
|
|
||||||
clone_repo
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def stage
|
def stage
|
||||||
# FIXME: The export command doesn't work on checkouts
|
# FIXME: The export command doesn't work on checkouts
|
||||||
# See https://bugs.launchpad.net/bzr/+bug/897511
|
# See https://bugs.launchpad.net/bzr/+bug/897511
|
||||||
@ -768,21 +720,6 @@ class BazaarDownloadStrategy < VCSDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
class FossilDownloadStrategy < VCSDownloadStrategy
|
class FossilDownloadStrategy < VCSDownloadStrategy
|
||||||
def fetch
|
|
||||||
ohai "Cloning #{@url}"
|
|
||||||
|
|
||||||
if @clone.exist? && repo_valid?
|
|
||||||
puts "Updating #{@clone}"
|
|
||||||
update
|
|
||||||
elsif @clone.exist?
|
|
||||||
puts "Removing invalid fossil repo from cache"
|
|
||||||
clear_cache
|
|
||||||
clone_repo
|
|
||||||
else
|
|
||||||
clone_repo
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def stage
|
def stage
|
||||||
# TODO: The 'open' and 'checkout' commands are very noisy and have no '-q' option.
|
# TODO: The 'open' and 'checkout' commands are very noisy and have no '-q' option.
|
||||||
safe_system fossilpath, 'open', @clone
|
safe_system fossilpath, 'open', @clone
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user