Fixes nil error when svn binary version is unknown (#1607).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1652 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
9ff53f97ee
commit
622b6121f4
|
@ -26,15 +26,24 @@ module Redmine
|
|||
class AbstractAdapter #:nodoc:
|
||||
class << self
|
||||
# Returns the version of the scm client
|
||||
# Eg: [1, 5, 0]
|
||||
# Eg: [1, 5, 0] or [] if unknown
|
||||
def client_version
|
||||
'Unknown version'
|
||||
[]
|
||||
end
|
||||
|
||||
# Returns the version string of the scm client
|
||||
# Eg: '1.5.0'
|
||||
# Eg: '1.5.0' or 'Unknown version' if unknown
|
||||
def client_version_string
|
||||
client_version.is_a?(Array) ? client_version.join('.') : client_version.to_s
|
||||
v = client_version || 'Unknown version'
|
||||
v.is_a?(Array) ? v.join('.') : v.to_s
|
||||
end
|
||||
|
||||
# Returns true if the current client version is above
|
||||
# or equals the given one
|
||||
# If option is :unknown is set to true, it will return
|
||||
# true if the client version is unknown
|
||||
def client_version_above?(v, options={})
|
||||
((client_version <=> v) >= 0) || (client_version.empty? && options[:unknown])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ module Redmine
|
|||
|
||||
class << self
|
||||
def client_version
|
||||
@@client_version ||= (hgversion || 'Unknown version')
|
||||
@@client_version ||= (hgversion || [])
|
||||
end
|
||||
|
||||
def hgversion
|
||||
|
@ -52,7 +52,7 @@ module Redmine
|
|||
end
|
||||
|
||||
def template_path_for(version)
|
||||
if version.is_a?(String) or ((version <=> [0,9,5]) > 0)
|
||||
if ((version <=> [0,9,5]) > 0) || version.empty?
|
||||
ver = "1.0"
|
||||
else
|
||||
ver = "0.9.5"
|
||||
|
|
|
@ -28,7 +28,7 @@ module Redmine
|
|||
|
||||
class << self
|
||||
def client_version
|
||||
@@client_version ||= (svn_binary_version || 'Unknown version')
|
||||
@@client_version ||= (svn_binary_version || [])
|
||||
end
|
||||
|
||||
def svn_binary_version
|
||||
|
@ -109,7 +109,7 @@ module Redmine
|
|||
|
||||
def properties(path, identifier=nil)
|
||||
# proplist xml output supported in svn 1.5.0 and higher
|
||||
return nil if (self.class.client_version <=> [1, 5, 0]) < 0
|
||||
return nil unless self.class.client_version_above?([1, 5, 0])
|
||||
|
||||
identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
|
||||
cmd = "#{SVN_BIN} proplist --verbose --xml #{target(path)}@#{identifier}"
|
||||
|
|
|
@ -25,7 +25,7 @@ begin
|
|||
def test_template_path
|
||||
to_test = { [0,9,5] => "0.9.5",
|
||||
[1,0] => "1.0",
|
||||
"Unknown version" => "1.0",
|
||||
[] => "1.0",
|
||||
[1,0,1] => "1.0"}
|
||||
|
||||
to_test.each do |v, template|
|
||||
|
|
Loading…
Reference in New Issue