]> source.dussan.org Git - redmine.git/commitdiff
scm: git: lib: add parents to Revision class (#5501)
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Fri, 28 Oct 2011 04:58:26 +0000 (04:58 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Fri, 28 Oct 2011 04:58:26 +0000 (04:58 +0000)
Contributed by Jan TopiƄski.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7668 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/scm/adapters/git_adapter.rb

index 6fe31cb71f89a03f039f8a937f087d53481f95f7..f5dfbe2ae123e708c2d19bc22821414bd28fa178 100644 (file)
@@ -185,7 +185,7 @@ module Redmine
 
         def revisions(path, identifier_from, identifier_to, options={})
           revs = Revisions.new
-          cmd_args = %w|log --no-color --encoding=UTF-8 --raw --date=iso --pretty=fuller|
+          cmd_args = %w|log --no-color --encoding=UTF-8 --raw --date=iso --pretty=fuller --parents|
           cmd_args << "--reverse" if options[:reverse]
           cmd_args << "--all" if options[:all]
           cmd_args << "-n" << "#{options[:limit].to_i}" if options[:limit]
@@ -202,9 +202,10 @@ module Redmine
             parsing_descr = 0  #0: not parsing desc or files, 1: parsing desc, 2: parsing files
 
             io.each_line do |line|
-              if line =~ /^commit ([0-9a-f]{40})$/
+              if line =~ /^commit ([0-9a-f]{40})(( [0-9a-f]{40})*)$/
                 key = "commit"
                 value = $1
+                parents_str = $2
                 if (parsing_descr == 1 || parsing_descr == 2)
                   parsing_descr = 0
                   revision = Revision.new({
@@ -213,7 +214,8 @@ module Redmine
                     :author     => changeset[:author],
                     :time       => Time.parse(changeset[:date]),
                     :message    => changeset[:description],
-                    :paths      => files
+                    :paths      => files,
+                    :parents    => changeset[:parents]
                   })
                   if block_given?
                     yield revision
@@ -224,6 +226,9 @@ module Redmine
                   files = []
                 end
                 changeset[:commit] = $1
+                unless parents_str.nil? or parents_str == ""
+                  changeset[:parents] = parents_str.strip.split(' ')
+                end
               elsif (parsing_descr == 0) && line =~ /^(\w+):\s*(.*)$/
                 key = $1
                 value = $2
@@ -263,7 +268,8 @@ module Redmine
                 :author     => changeset[:author],
                 :time       => Time.parse(changeset[:date]),
                 :message    => changeset[:description],
-                :paths      => files
+                :paths      => files,
+                :parents    => changeset[:parents]
                  })
               if block_given?
                 yield revision