Project

General

Profile

Patch #5117 » hg-version-minimal-2010-11-15.patch

Yuya Nishihara, 2010-11-14 17:29

View differences:

lib/redmine/scm/adapters/mercurial_adapter.rb
38 38
            # release number (eg 0.9.5 or 1.0) or as a revision
39 39
            # id composed of 12 hexa characters.
40 40
            theversion = hgversion_from_command_line
41
            if theversion.match(/^\d+(\.\d+)+/)
42
              theversion.split(".").collect(&:to_i)
41
            if m = theversion.match(/\b\d+(\.\d+)+\b/)
42
              m[0].split(".").collect(&:to_i)
43 43
            end
44 44
          end
45 45
          
46 46
          def hgversion_from_command_line
47
            %x{#{HG_BIN} --version}.match(/\(version (.*)\)/)[1]
47
            %x{#{HG_BIN} --version}.lines.first.to_s
48 48
          end
49 49
          
50 50
          def template_path
test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb
11 11
    REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
12 12
    
13 13
    def test_hgversion
14
      to_test = { "0.9.5" => [0,9,5],
15
                  "1.0" => [1,0],
16
                  "1e4ddc9ac9f7+20080325" => nil,
17
                  "1.0.1+20080525" => [1,0,1],
18
                  "1916e629a29d" => nil}
14
      to_test = { "Mercurial Distributed SCM (version 0.9.5)\n" => [0,9,5],
15
                  "Mercurial Distributed SCM (1.0)\n" => [1,0],
16
                  "Mercurial Distributed SCM (1e4ddc9ac9f7+20080325)\n" => nil,
17
                  "Mercurial Distributed SCM (1.0.1+20080525)\n" => [1,0,1],
18
                  "Mercurial Distributed SCM (1916e629a29d)\n" => nil,
19
                  "Mercurial SCM Distribuito (versione 0.9.5)\n" => [0,9,5]}
19 20
      
20 21
      to_test.each do |s, v|
21 22
        test_hgversion_for(s, v)
(9-9/13)