2 class SvnAdapter < AbstractAdapter
4 /^(file|http|https|svn):\/\/(\/)?[A-Za-z0-9_\-\.]+(:\d+)?(\/[A-Za-z0-9_\-\.\/\+%^~]*)?$/
7 def self.public_url_regex
8 /^(http|https|svn):\/\/[A-Za-z0-9_\-\.]+(:\d+)?(\/[A-Za-z0-9_\-\.\/\+%^~]*)?$/
13 @url = path_to_file_url(@url)
14 @url = force_https_if_sourceforge(@url)
15 @branch_name = @branch_name[0..-2] if @branch_name && @branch_name[-1..-1] == '/'
19 # If the URL is a simple directory path, make sure it is prefixed by file://
20 def path_to_file_url(path)
21 url =~ /:\/\// ? url : 'file://' + File.expand_path(path)
24 def force_https_if_sourceforge(url)
25 # SourceForge requires https for svnsync
26 url =~ /http(:\/\/.*svn\.sourceforge\.net.*)/ ? "https#{$1}" : url
29 def validate_server_connection
33 @errors << [:failed, "The server did not respond to a 'svn info' command. Is the URL correct?"]
34 elsif self.url[0..root.length] != root
35 @errors << [:failed, "The URL did not match the Subversion root #{root}. Is the URL correct?"]
37 @errors << [:failed, "The server did not respond to a 'svn ls' command. Is the URL correct?"]
40 logger.error { $!.inspect }
41 @errors << [:failed, "An error occured connecting to the server. Check the URL, username, and password."]
45 # From the given URL, determine which part of it is the root and which part of it is the branch_name.
46 # The current branch_name is overwritten.
47 def recalc_branch_name
48 @branch_name = @url ? @url[root.length..-1] : @branch_name
49 @branch_name = @branch_name[0..-2] if @branch_name[-1..-1] == '/'
53 u = @url =~ /:\/\/(.*\.?svn\.)?([^\/^:]+)(:\d+)?\// ? $2 : nil
55 when /(googlecode\.com$)/, /(tigris\.org$)/, /(sunsource\.net$)/, /(java\.net$)/,
56 /(openoffice\.org$)/, /(netbeans\.org$)/, /(dev2dev\.bea\.com$)/