##// END OF EJS Templates
Fixes nil error when svn binary version is unknown (#1607)....
Jean-Philippe Lang -
r1638:622b6121f48f
parent child
Show More
@@ -26,15 +26,24 module Redmine
26 26 class AbstractAdapter #:nodoc:
27 27 class << self
28 28 # Returns the version of the scm client
29 # Eg: [1, 5, 0]
29 # Eg: [1, 5, 0] or [] if unknown
30 30 def client_version
31 'Unknown version'
31 []
32 32 end
33 33
34 34 # Returns the version string of the scm client
35 # Eg: '1.5.0'
35 # Eg: '1.5.0' or 'Unknown version' if unknown
36 36 def client_version_string
37 client_version.is_a?(Array) ? client_version.join('.') : client_version.to_s
37 v = client_version || 'Unknown version'
38 v.is_a?(Array) ? v.join('.') : v.to_s
39 end
40
41 # Returns true if the current client version is above
42 # or equals the given one
43 # If option is :unknown is set to true, it will return
44 # true if the client version is unknown
45 def client_version_above?(v, options={})
46 ((client_version <=> v) >= 0) || (client_version.empty? && options[:unknown])
38 47 end
39 48 end
40 49
@@ -30,7 +30,7 module Redmine
30 30
31 31 class << self
32 32 def client_version
33 @@client_version ||= (hgversion || 'Unknown version')
33 @@client_version ||= (hgversion || [])
34 34 end
35 35
36 36 def hgversion
@@ -52,7 +52,7 module Redmine
52 52 end
53 53
54 54 def template_path_for(version)
55 if version.is_a?(String) or ((version <=> [0,9,5]) > 0)
55 if ((version <=> [0,9,5]) > 0) || version.empty?
56 56 ver = "1.0"
57 57 else
58 58 ver = "0.9.5"
@@ -28,7 +28,7 module Redmine
28 28
29 29 class << self
30 30 def client_version
31 @@client_version ||= (svn_binary_version || 'Unknown version')
31 @@client_version ||= (svn_binary_version || [])
32 32 end
33 33
34 34 def svn_binary_version
@@ -109,7 +109,7 module Redmine
109 109
110 110 def properties(path, identifier=nil)
111 111 # proplist xml output supported in svn 1.5.0 and higher
112 return nil if (self.class.client_version <=> [1, 5, 0]) < 0
112 return nil unless self.class.client_version_above?([1, 5, 0])
113 113
114 114 identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
115 115 cmd = "#{SVN_BIN} proplist --verbose --xml #{target(path)}@#{identifier}"
@@ -25,7 +25,7 begin
25 25 def test_template_path
26 26 to_test = { [0,9,5] => "0.9.5",
27 27 [1,0] => "1.0",
28 "Unknown version" => "1.0",
28 [] => "1.0",
29 29 [1,0,1] => "1.0"}
30 30
31 31 to_test.each do |v, template|
General Comments 0
You need to be logged in to leave comments. Login now