Add clone_repo to remaining VCS strategies
This commit is contained in:
parent
8debc18839
commit
3a20562d6e
@ -72,6 +72,9 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clone_repo
|
||||||
|
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]
|
||||||
@ -586,20 +589,15 @@ class CVSDownloadStrategy < VCSDownloadStrategy
|
|||||||
def fetch
|
def fetch
|
||||||
ohai "Checking out #{@url}"
|
ohai "Checking out #{@url}"
|
||||||
|
|
||||||
# URL of cvs cvs://:pserver:anoncvs@www.gccxml.org:/cvsroot/GCC_XML:gccxml
|
if @clone.exist? && repo_valid?
|
||||||
# will become:
|
|
||||||
# cvs -d :pserver:anoncvs@www.gccxml.org:/cvsroot/GCC_XML login
|
|
||||||
# cvs -d :pserver:anoncvs@www.gccxml.org:/cvsroot/GCC_XML co gccxml
|
|
||||||
mod, url = split_url(@url)
|
|
||||||
|
|
||||||
unless @clone.exist?
|
|
||||||
HOMEBREW_CACHE.cd do
|
|
||||||
safe_system cvspath, '-d', url, 'login'
|
|
||||||
safe_system cvspath, '-d', url, 'checkout', '-d', cache_filename, mod
|
|
||||||
end
|
|
||||||
else
|
|
||||||
puts "Updating #{@clone}"
|
puts "Updating #{@clone}"
|
||||||
@clone.cd { safe_system cvspath, 'up' }
|
@clone.cd { safe_system cvspath, "up" }
|
||||||
|
elsif @clone.exist?
|
||||||
|
puts "Removing invalid CVS repo from cache"
|
||||||
|
clear_cache
|
||||||
|
clone_repo
|
||||||
|
else
|
||||||
|
clone_repo
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -617,6 +615,19 @@ class CVSDownloadStrategy < VCSDownloadStrategy
|
|||||||
@clone.join("CVS").directory?
|
@clone.join("CVS").directory?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clone_repo
|
||||||
|
# URL of cvs cvs://:pserver:anoncvs@www.gccxml.org:/cvsroot/GCC_XML:gccxml
|
||||||
|
# will become:
|
||||||
|
# cvs -d :pserver:anoncvs@www.gccxml.org:/cvsroot/GCC_XML login
|
||||||
|
# cvs -d :pserver:anoncvs@www.gccxml.org:/cvsroot/GCC_XML co gccxml
|
||||||
|
mod, url = split_url(@url)
|
||||||
|
|
||||||
|
HOMEBREW_CACHE.cd do
|
||||||
|
safe_system cvspath, "-d", url, "login"
|
||||||
|
safe_system cvspath, "-d", url, "checkout", "-d", cache_filename, mod
|
||||||
|
end
|
||||||
|
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
|
||||||
@ -650,11 +661,6 @@ class MercurialDownloadStrategy < VCSDownloadStrategy
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def clone_repo
|
|
||||||
url = @url.sub(%r[^hg://], '')
|
|
||||||
safe_system hgpath, 'clone', url, @clone
|
|
||||||
end
|
|
||||||
|
|
||||||
def stage
|
def stage
|
||||||
dst = Dir.getwd
|
dst = Dir.getwd
|
||||||
@clone.cd do
|
@clone.cd do
|
||||||
@ -677,6 +683,11 @@ class MercurialDownloadStrategy < VCSDownloadStrategy
|
|||||||
@clone.join(".hg").directory?
|
@clone.join(".hg").directory?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clone_repo
|
||||||
|
url = @url.sub(%r[^hg://], "")
|
||||||
|
safe_system hgpath, "clone", url, @clone
|
||||||
|
end
|
||||||
|
|
||||||
def hgpath
|
def hgpath
|
||||||
@path ||= %W[
|
@path ||= %W[
|
||||||
#{which("hg")}
|
#{which("hg")}
|
||||||
@ -702,12 +713,6 @@ class BazaarDownloadStrategy < VCSDownloadStrategy
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def clone_repo
|
|
||||||
url = @url.sub(%r[^bzr://], '')
|
|
||||||
# 'lightweight' means history-less
|
|
||||||
safe_system bzrpath, 'checkout', '--lightweight', url, @clone
|
|
||||||
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
|
||||||
@ -725,6 +730,12 @@ class BazaarDownloadStrategy < VCSDownloadStrategy
|
|||||||
@clone.join(".bzr").directory?
|
@clone.join(".bzr").directory?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clone_repo
|
||||||
|
url = @url.sub(%r[^bzr://], "")
|
||||||
|
# "lightweight" means history-less
|
||||||
|
safe_system bzrpath, "checkout", "--lightweight", url, @clone
|
||||||
|
end
|
||||||
|
|
||||||
def bzrpath
|
def bzrpath
|
||||||
@path ||= %W[
|
@path ||= %W[
|
||||||
#{which("bzr")}
|
#{which("bzr")}
|
||||||
@ -736,12 +747,16 @@ end
|
|||||||
class FossilDownloadStrategy < VCSDownloadStrategy
|
class FossilDownloadStrategy < VCSDownloadStrategy
|
||||||
def fetch
|
def fetch
|
||||||
ohai "Cloning #{@url}"
|
ohai "Cloning #{@url}"
|
||||||
unless @clone.exist?
|
|
||||||
url=@url.sub(%r[^fossil://], '')
|
if @clone.exist? && repo_valid?
|
||||||
safe_system fossilpath, 'clone', url, @clone
|
|
||||||
else
|
|
||||||
puts "Updating #{@clone}"
|
puts "Updating #{@clone}"
|
||||||
safe_system fossilpath, 'pull', '-R', @clone
|
safe_system fossilpath, "pull", "-R", @clone
|
||||||
|
elsif @clone.exist?
|
||||||
|
puts "Removing invalid fossil repo from cache"
|
||||||
|
clear_cache
|
||||||
|
clone_repo
|
||||||
|
else
|
||||||
|
clone_repo
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -764,6 +779,11 @@ class FossilDownloadStrategy < VCSDownloadStrategy
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clone_repo
|
||||||
|
url = @url.sub(%r[^fossil://], "")
|
||||||
|
safe_system fossilpath, "clone", url, @clone
|
||||||
|
end
|
||||||
|
|
||||||
def fossilpath
|
def fossilpath
|
||||||
@path ||= %W[
|
@path ||= %W[
|
||||||
#{which("fossil")}
|
#{which("fossil")}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user