summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/redmine/scm/adapters/abstract_adapter.rb17
-rw-r--r--lib/redmine/scm/adapters/mercurial_adapter.rb4
-rw-r--r--lib/redmine/scm/adapters/subversion_adapter.rb4
-rw-r--r--test/unit/mercurial_adapter_test.rb2
4 files changed, 18 insertions, 9 deletions
diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb
index a876de937..c48ed2068 100644
--- a/lib/redmine/scm/adapters/abstract_adapter.rb
+++ b/lib/redmine/scm/adapters/abstract_adapter.rb
@@ -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
diff --git a/lib/redmine/scm/adapters/mercurial_adapter.rb b/lib/redmine/scm/adapters/mercurial_adapter.rb
index a201db933..4eed776d8 100644
--- a/lib/redmine/scm/adapters/mercurial_adapter.rb
+++ b/lib/redmine/scm/adapters/mercurial_adapter.rb
@@ -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"
diff --git a/lib/redmine/scm/adapters/subversion_adapter.rb b/lib/redmine/scm/adapters/subversion_adapter.rb
index 90940715d..2b7f0192e 100644
--- a/lib/redmine/scm/adapters/subversion_adapter.rb
+++ b/lib/redmine/scm/adapters/subversion_adapter.rb
@@ -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}"
diff --git a/test/unit/mercurial_adapter_test.rb b/test/unit/mercurial_adapter_test.rb
index 4fecebe24..a2673ad42 100644
--- a/test/unit/mercurial_adapter_test.rb
+++ b/test/unit/mercurial_adapter_test.rb
@@ -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|