From 01a9e17c49af318eb7e42b8833fe913c918998c2 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 15 Jul 2013 21:06:54 +0000 Subject: [PATCH] CVS root_url not recognized when connection string does not include port (#14422). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12027 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/scm/adapters/cvs_adapter.rb | 2 +- .../lib/redmine/scm/adapters/cvs_adapter_test.rb | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/redmine/scm/adapters/cvs_adapter.rb b/lib/redmine/scm/adapters/cvs_adapter.rb index 3a0d27c34..d1096e725 100644 --- a/lib/redmine/scm/adapters/cvs_adapter.rb +++ b/lib/redmine/scm/adapters/cvs_adapter.rb @@ -335,7 +335,7 @@ module Redmine # :pserver:anonymous@foo.bar:/path => /path # :ext:cvsservername:/path => /path def root_url_path - root_url.to_s.gsub(/^:.+:\d*/, '') + root_url.to_s.gsub(%r{^:.+?(?=/)}, '') end # convert a date/time into the CVS-format diff --git a/test/unit/lib/redmine/scm/adapters/cvs_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/cvs_adapter_test.rb index fd931316e..d9ca7af0c 100644 --- a/test/unit/lib/redmine/scm/adapters/cvs_adapter_test.rb +++ b/test/unit/lib/redmine/scm/adapters/cvs_adapter_test.rb @@ -80,8 +80,19 @@ begin end def test_root_url_path - adapter = Redmine::Scm::Adapters::CvsAdapter.new('foo', ':pserver:cvs_user:cvs_password@123.456.789.123:9876/repo') - assert_equal '/repo', adapter.send(:root_url_path) + to_test = { + ':pserver:cvs_user:cvs_password@123.456.789.123:9876/repo' => '/repo', + ':pserver:cvs_user:cvs_password@123.456.789.123/repo' => '/repo', + ':pserver:cvs_user:cvs_password@cvs_server:/repo' => '/repo', + ':pserver:cvs_user:cvs_password@cvs_server:9876/repo' => '/repo', + ':pserver:cvs_user:cvs_password@cvs_server/repo' => '/repo', + ':pserver:cvs_user:cvs_password@cvs_server/path/repo' => '/path/repo', + ':ext:cvsservername:/path' => '/path' + } + + to_test.each do |string, expected| + assert_equal expected, Redmine::Scm::Adapters::CvsAdapter.new('foo', string).send(:root_url_path), "#{string} failed" + end end private