VCSDownloadStrategy: rename checkout_name to cache_filename
This commit is contained in:
parent
dd719e7ca6
commit
ed7f8faed2
@ -48,7 +48,7 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
|
|||||||
spec.each { |o| return o }
|
spec.each { |o| return o }
|
||||||
end
|
end
|
||||||
|
|
||||||
def checkout_name(tag)
|
def cache_filename(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
|
||||||
@ -321,9 +321,9 @@ class SubversionDownloadStrategy < VCSDownloadStrategy
|
|||||||
@@svn ||= 'svn'
|
@@svn ||= 'svn'
|
||||||
|
|
||||||
if ARGV.build_head?
|
if ARGV.build_head?
|
||||||
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{checkout_name("svn-HEAD")}")
|
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("svn-HEAD")}")
|
||||||
else
|
else
|
||||||
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{checkout_name("svn")}")
|
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("svn")}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -427,7 +427,7 @@ class GitDownloadStrategy < VCSDownloadStrategy
|
|||||||
def initialize name, resource
|
def initialize name, resource
|
||||||
super
|
super
|
||||||
@@git ||= 'git'
|
@@git ||= 'git'
|
||||||
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{checkout_name("git")}")
|
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("git")}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch
|
def fetch
|
||||||
@ -570,7 +570,7 @@ end
|
|||||||
class CVSDownloadStrategy < VCSDownloadStrategy
|
class CVSDownloadStrategy < VCSDownloadStrategy
|
||||||
def initialize name, resource
|
def initialize name, resource
|
||||||
super
|
super
|
||||||
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{checkout_name("cvs")}")
|
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("cvs")}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch
|
def fetch
|
||||||
@ -585,7 +585,7 @@ class CVSDownloadStrategy < VCSDownloadStrategy
|
|||||||
unless @clone.exist?
|
unless @clone.exist?
|
||||||
HOMEBREW_CACHE.cd do
|
HOMEBREW_CACHE.cd do
|
||||||
safe_system '/usr/bin/cvs', '-d', url, 'login'
|
safe_system '/usr/bin/cvs', '-d', url, 'login'
|
||||||
safe_system '/usr/bin/cvs', '-d', url, 'checkout', '-d', checkout_name("cvs"), mod
|
safe_system '/usr/bin/cvs', '-d', url, 'checkout', '-d', cache_filename("cvs"), mod
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
puts "Updating #{@clone}"
|
puts "Updating #{@clone}"
|
||||||
@ -618,7 +618,7 @@ end
|
|||||||
class MercurialDownloadStrategy < VCSDownloadStrategy
|
class MercurialDownloadStrategy < VCSDownloadStrategy
|
||||||
def initialize name, resource
|
def initialize name, resource
|
||||||
super
|
super
|
||||||
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{checkout_name("hg")}")
|
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("hg")}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def hgpath
|
def hgpath
|
||||||
@ -671,7 +671,7 @@ end
|
|||||||
class BazaarDownloadStrategy < VCSDownloadStrategy
|
class BazaarDownloadStrategy < VCSDownloadStrategy
|
||||||
def initialize name, resource
|
def initialize name, resource
|
||||||
super
|
super
|
||||||
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{checkout_name("bzr")}")
|
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("bzr")}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def bzrpath
|
def bzrpath
|
||||||
@ -717,7 +717,7 @@ end
|
|||||||
class FossilDownloadStrategy < VCSDownloadStrategy
|
class FossilDownloadStrategy < VCSDownloadStrategy
|
||||||
def initialize name, resource
|
def initialize name, resource
|
||||||
super
|
super
|
||||||
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{checkout_name("fossil")}")
|
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("fossil")}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def fossilpath
|
def fossilpath
|
||||||
|
|||||||
@ -37,7 +37,7 @@ class AbstractDownloadStrategyTests < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class DownloadStrategyCheckoutNameTests < Test::Unit::TestCase
|
class VCSDownloadStrategyTests < Test::Unit::TestCase
|
||||||
def setup
|
def setup
|
||||||
@resource = ResourceDouble.new("http://foo.com/bar")
|
@resource = ResourceDouble.new("http://foo.com/bar")
|
||||||
@strategy = VCSDownloadStrategy
|
@strategy = VCSDownloadStrategy
|
||||||
@ -49,17 +49,17 @@ class DownloadStrategyCheckoutNameTests < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_explicit_name
|
def test_explicit_name
|
||||||
downloader = @strategy.new("baz", @resource)
|
downloader = @strategy.new("baz", @resource)
|
||||||
assert_equal "baz--foo", downloader.checkout_name("foo")
|
assert_equal "baz--foo", downloader.cache_filename("foo")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_empty_name
|
def test_empty_name
|
||||||
downloader = @strategy.new("", @resource)
|
downloader = @strategy.new("", @resource)
|
||||||
assert_equal escaped("foo"), downloader.checkout_name("foo")
|
assert_equal escaped("foo"), downloader.cache_filename("foo")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_unknown_name
|
def test_unknown_name
|
||||||
downloader = @strategy.new("__UNKNOWN__", @resource)
|
downloader = @strategy.new("__UNKNOWN__", @resource)
|
||||||
assert_equal escaped("foo"), downloader.checkout_name("foo")
|
assert_equal escaped("foo"), downloader.cache_filename("foo")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user