hg-version-2010-11-21.diff

Toshi MARUYAMA, 2010-11-21 02:28

Download (2.5 KB)

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 m = theversion.match(/\b\d+(\.\d+)+\b/)
42
              m[0].split(".").collect(&:to_i)
41
            if m = theversion.match(%r{\A(.*?)((\d+\.)+\d+)})
42
              m[2].scan(%r{\d+}).collect(&:to_i)
43 43
            end
44 44
          end
45 45
          
46 46
          def hgversion_from_command_line
47
            %x{#{HG_BIN} --version}.lines.first.to_s
47
            shellout("#{HG_BIN} --version") { |io| io.read }.to_s
48 48
          end
49 49
          
50 50
          def template_path
test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb
16 16
                  "Mercurial Distributed SCM (1e4ddc9ac9f7+20080325)\n" => nil,
17 17
                  "Mercurial Distributed SCM (1.0.1+20080525)\n" => [1,0,1],
18 18
                  "Mercurial Distributed SCM (1916e629a29d)\n" => nil,
19
                  "Mercurial SCM Distribuito (versione 0.9.5)\n" => [0,9,5]}
20
      
19
                  "Mercurial SCM Distribuito (versione 0.9.5)\n" => [0,9,5],
20
                  "(1.6)\n(1.7)\n(1.8)"           => [1,6],
21
                  "(1.7.1)\r\n(1.8.1)\r\n(1.9.1)" => [1,7,1]}
22

  
21 23
      to_test.each do |s, v|
22 24
        test_hgversion_for(s, v)
23 25
      end
......
27 29
      to_test = { [0,9,5] => "0.9.5",
28 30
                  [1,0] => "1.0",
29 31
                  [] => "1.0",
30
                  [1,0,1] => "1.0"}
31
      
32
                  [1,0,1] => "1.0",
33
                  [1,7]   => "1.0",
34
                  [1,7,1] => "1.0"}
32 35
      to_test.each do |v, template|
33 36
        test_template_path_for(v, template)
34 37
      end
......
50 53
  end
51 54
  
52 55
rescue LoadError
53
  def test_fake; assert(false, "Requires mocha to run those tests")  end
56
  class MercurialMochaFake < ActiveSupport::TestCase
57
    def test_fake; assert(false, "Requires mocha to run those tests")  end
58
  end
54 59
end
60