From 8cf0f34aa75aff18383fc4aa105d831be941f59f Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sun, 7 Apr 2013 00:49:56 -0500 Subject: [PATCH] Download strategies require a usable name We should handle this case in some predictable way, but until we do, let's raise a more appropriate exception. It would also be good to get rid of the duplication here. --- Library/Homebrew/download_strategy.rb | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 80631d86c2..27542a3fd6 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -209,9 +209,14 @@ class SubversionDownloadStrategy < AbstractDownloadStrategy def initialize name, package super @@svn ||= 'svn' - @unique_token="#{name}--svn" unless name.to_s.empty? or name == '__UNKNOWN__' - @unique_token += "-HEAD" if ARGV.include? '--HEAD' - @co=HOMEBREW_CACHE+@unique_token + + if name.to_s.empty? || name == '__UNKNOWN__' + raise NotImplementedError, "strategy requires a name parameter" + else + @co = HOMEBREW_CACHE + "#{name}--svn" + end + + @co << "-HEAD" if ARGV.build_head? end def cached_location @@ -307,8 +312,12 @@ class GitDownloadStrategy < AbstractDownloadStrategy def initialize name, package super @@git ||= 'git' - @unique_token="#{name}--git" unless name.to_s.empty? or name == '__UNKNOWN__' - @clone=HOMEBREW_CACHE+@unique_token + + if name.to_s.empty? || name == '__UNKNOWN__' + raise NotImplementedError, "strategy requires a name parameter" + else + @clone = HOMEBREW_CACHE + "#{name}--git" + end end def cached_location @@ -457,8 +466,12 @@ end class CVSDownloadStrategy < AbstractDownloadStrategy def initialize name, package super - @unique_token="#{name}--cvs" unless name.to_s.empty? or name == '__UNKNOWN__' - @co=HOMEBREW_CACHE+@unique_token + + if name.to_s.empty? || name == '__UNKNOWN__' + raise NotImplementedError, "strategy requires a name parameter" + else + @co = HOMEBREW_CACHE + "#{name}--cvs" + end end def cached_location; @co; end