scm: subversion: refactor getting svn version and add lib test (#4273).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4825 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA
2011-02-15 02:12:39 +00:00
parent 60d80653ba
commit 41f190e8ed
2 changed files with 32 additions and 10 deletions

View File

@@ -38,19 +38,21 @@ module Redmine
def client_version
@@client_version ||= (svn_binary_version || [])
end
def client_available
!client_version.empty?
end
def svn_binary_version
cmd = "#{sq_bin} --version"
version = nil
shellout(cmd) do |io|
# Read svn version in first returned line
if m = io.read.to_s.match(%r{\A(.*?)((\d+\.)+\d+)})
version = m[2].scan(%r{\d+}).collect(&:to_i)
end
end
return nil if $? && $?.exitstatus != 0
version
scm_version = scm_version_from_command_line
if m = scm_version.match(%r{\A(.*?)((\d+\.)+\d+)})
m[2].scan(%r{\d+}).collect(&:to_i)
end
end
def scm_version_from_command_line
shellout("#{sq_bin} --version") { |io| io.read }.to_s
end
end
# Get info about the svn repository