From 663ea030fc8a93ae66e6fbf148d7af88eec7c6cf Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Wed, 17 Mar 2010 16:56:06 -0700 Subject: [PATCH] Allow :using on head to specify a download strategy. A 'head' in a formula can now specify which download strategy to use via a ':using' specification: head 'http://svn.macosforge.org/repository/darwinbuild/trunk/', :using => :svn This reduces the number of cases where "download_strategy" needs to be overriden. --- Library/Homebrew/formula.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 1bb4889d17..2bba3d4e7f 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -134,6 +134,23 @@ class Formula # reimplement if we don't autodetect the download strategy you require def download_strategy + vcs = @specs.delete :using + if vcs != nil + # If a class is passed, assume it is a download strategy + return vcs if vcs.kind_of? Class + + case vcs + when :bzr then return BazaarDownloadStrategy + when :curl then return CurlDownloadStrategy + when :cvs then return CVSDownloadStrategy + when :git then return GitDownloadStrategy + when :hg then return MercurialDownloadStrategy + when :svn then return SubversionDownloadStrategy + end + + raise "Unknown strategy #{vcs} was requested." + end + detect_download_strategy url end