VCSDownloadStrategy: pull construction of @clone into superclass
This commit is contained in:
parent
ed7f8faed2
commit
932091f9e0
@ -42,13 +42,14 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
|
|||||||
def initialize name, resource
|
def initialize name, resource
|
||||||
super
|
super
|
||||||
@ref_type, @ref = destructure_spec_hash(resource.specs)
|
@ref_type, @ref = destructure_spec_hash(resource.specs)
|
||||||
|
@clone = HOMEBREW_CACHE/cache_filename
|
||||||
end
|
end
|
||||||
|
|
||||||
def destructure_spec_hash(spec)
|
def destructure_spec_hash(spec)
|
||||||
spec.each { |o| return o }
|
spec.each { |o| return o }
|
||||||
end
|
end
|
||||||
|
|
||||||
def cache_filename(tag)
|
def cache_filename(tag=cache_tag)
|
||||||
if name.empty? || name == '__UNKNOWN__'
|
if name.empty? || name == '__UNKNOWN__'
|
||||||
"#{ERB::Util.url_encode(@url)}--#{tag}"
|
"#{ERB::Util.url_encode(@url)}--#{tag}"
|
||||||
else
|
else
|
||||||
@ -56,6 +57,10 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cache_tag
|
||||||
|
"__UNKNOWN__"
|
||||||
|
end
|
||||||
|
|
||||||
def cached_location
|
def cached_location
|
||||||
@clone
|
@clone
|
||||||
end
|
end
|
||||||
@ -316,15 +321,10 @@ class S3DownloadStrategy < CurlDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
class SubversionDownloadStrategy < VCSDownloadStrategy
|
class SubversionDownloadStrategy < VCSDownloadStrategy
|
||||||
def initialize name, resource
|
@@svn ||= 'svn'
|
||||||
super
|
|
||||||
@@svn ||= 'svn'
|
|
||||||
|
|
||||||
if ARGV.build_head?
|
def cache_tag
|
||||||
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("svn-HEAD")}")
|
ARGV.build_head? ? "svn-HEAD" : "svn"
|
||||||
else
|
|
||||||
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("svn")}")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def repo_valid?
|
def repo_valid?
|
||||||
@ -424,11 +424,9 @@ class UnsafeSubversionDownloadStrategy < SubversionDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
class GitDownloadStrategy < VCSDownloadStrategy
|
class GitDownloadStrategy < VCSDownloadStrategy
|
||||||
def initialize name, resource
|
@@git ||= 'git'
|
||||||
super
|
|
||||||
@@git ||= 'git'
|
def cache_tag; "git" end
|
||||||
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("git")}")
|
|
||||||
end
|
|
||||||
|
|
||||||
def fetch
|
def fetch
|
||||||
ohai "Cloning #@url"
|
ohai "Cloning #@url"
|
||||||
@ -568,10 +566,7 @@ class GitDownloadStrategy < VCSDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
class CVSDownloadStrategy < VCSDownloadStrategy
|
class CVSDownloadStrategy < VCSDownloadStrategy
|
||||||
def initialize name, resource
|
def cache_tag; "cvs" end
|
||||||
super
|
|
||||||
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("cvs")}")
|
|
||||||
end
|
|
||||||
|
|
||||||
def fetch
|
def fetch
|
||||||
ohai "Checking out #{@url}"
|
ohai "Checking out #{@url}"
|
||||||
@ -616,10 +611,7 @@ class CVSDownloadStrategy < VCSDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
class MercurialDownloadStrategy < VCSDownloadStrategy
|
class MercurialDownloadStrategy < VCSDownloadStrategy
|
||||||
def initialize name, resource
|
def cache_tag; "hg" end
|
||||||
super
|
|
||||||
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("hg")}")
|
|
||||||
end
|
|
||||||
|
|
||||||
def hgpath
|
def hgpath
|
||||||
# #{HOMEBREW_PREFIX}/share/python/hg is deprecated, but we levae it in for a while
|
# #{HOMEBREW_PREFIX}/share/python/hg is deprecated, but we levae it in for a while
|
||||||
@ -669,10 +661,7 @@ class MercurialDownloadStrategy < VCSDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
class BazaarDownloadStrategy < VCSDownloadStrategy
|
class BazaarDownloadStrategy < VCSDownloadStrategy
|
||||||
def initialize name, resource
|
def cache_tag; "bzr" end
|
||||||
super
|
|
||||||
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("bzr")}")
|
|
||||||
end
|
|
||||||
|
|
||||||
def bzrpath
|
def bzrpath
|
||||||
@path ||= %W[
|
@path ||= %W[
|
||||||
@ -715,10 +704,7 @@ class BazaarDownloadStrategy < VCSDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
class FossilDownloadStrategy < VCSDownloadStrategy
|
class FossilDownloadStrategy < VCSDownloadStrategy
|
||||||
def initialize name, resource
|
def cache_tag; "fossil" end
|
||||||
super
|
|
||||||
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("fossil")}")
|
|
||||||
end
|
|
||||||
|
|
||||||
def fossilpath
|
def fossilpath
|
||||||
@path ||= %W[
|
@path ||= %W[
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user