aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Nagel2014-12-06 12:29:15 -0500
committerJack Nagel2014-12-06 15:02:49 -0500
commitd5089593c9da70c52724f1687b8b62b370427bd2 (patch)
tree18dddd9ffa34252fa622982b942d9e32c2d4fda7
parentab4c768e4a6926dbf0584ca92da71c1eb0d3e05f (diff)
downloadhomebrew-d5089593c9da70c52724f1687b8b62b370427bd2.tar.bz2
Add clone_repo to remaining VCS strategies
-rw-r--r--Library/Homebrew/download_strategy.rb78
1 files changed, 49 insertions, 29 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index 40d7940af..93c0ee0b6 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -72,6 +72,9 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
true
end
+ def clone_repo
+ end
+
def extract_ref(specs)
key = REF_TYPES.find { |type| specs.key?(type) }
return key, specs[key]
@@ -586,20 +589,15 @@ class CVSDownloadStrategy < VCSDownloadStrategy
def fetch
ohai "Checking out #{@url}"
- # 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)
-
- 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
+ if @clone.exist? && repo_valid?
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
@@ -617,6 +615,19 @@ class CVSDownloadStrategy < VCSDownloadStrategy
@clone.join("CVS").directory?
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)
parts=in_url.sub(%r[^cvs://], '').split(/:/)
mod=parts.pop
@@ -650,11 +661,6 @@ class MercurialDownloadStrategy < VCSDownloadStrategy
end
end
- def clone_repo
- url = @url.sub(%r[^hg://], '')
- safe_system hgpath, 'clone', url, @clone
- end
-
def stage
dst = Dir.getwd
@clone.cd do
@@ -677,6 +683,11 @@ class MercurialDownloadStrategy < VCSDownloadStrategy
@clone.join(".hg").directory?
end
+ def clone_repo
+ url = @url.sub(%r[^hg://], "")
+ safe_system hgpath, "clone", url, @clone
+ end
+
def hgpath
@path ||= %W[
#{which("hg")}
@@ -702,12 +713,6 @@ class BazaarDownloadStrategy < VCSDownloadStrategy
end
end
- def clone_repo
- url = @url.sub(%r[^bzr://], '')
- # 'lightweight' means history-less
- safe_system bzrpath, 'checkout', '--lightweight', url, @clone
- end
-
def stage
# FIXME: The export command doesn't work on checkouts
# See https://bugs.launchpad.net/bzr/+bug/897511
@@ -725,6 +730,12 @@ class BazaarDownloadStrategy < VCSDownloadStrategy
@clone.join(".bzr").directory?
end
+ def clone_repo
+ url = @url.sub(%r[^bzr://], "")
+ # "lightweight" means history-less
+ safe_system bzrpath, "checkout", "--lightweight", url, @clone
+ end
+
def bzrpath
@path ||= %W[
#{which("bzr")}
@@ -736,12 +747,16 @@ end
class FossilDownloadStrategy < VCSDownloadStrategy
def fetch
ohai "Cloning #{@url}"
- unless @clone.exist?
- url=@url.sub(%r[^fossil://], '')
- safe_system fossilpath, 'clone', url, @clone
- else
+
+ if @clone.exist? && repo_valid?
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
@@ -764,6 +779,11 @@ class FossilDownloadStrategy < VCSDownloadStrategy
true
end
+ def clone_repo
+ url = @url.sub(%r[^fossil://], "")
+ safe_system fossilpath, "clone", url, @clone
+ end
+
def fossilpath
@path ||= %W[
#{which("fossil")}