]> source.dussan.org Git - redmine.git/commitdiff
Git adapter: use commit time instead of author time (#2108).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 9 Nov 2008 12:07:35 +0000 (12:07 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 9 Nov 2008 12:07:35 +0000 (12:07 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@1999 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/scm/adapters/git_adapter.rb
test/unit/repository_git_test.rb

index c74aac7c1e7f98f02f7f525c57994b017335e2ef..47c19210536bb1cd62030749446b5f57f03ea4ae 100644 (file)
@@ -29,10 +29,10 @@ module Redmine
         def get_rev (rev,path)
         
           if rev != 'latest' && !rev.nil?
-            cmd="#{GIT_BIN} --git-dir #{target('')} show --date=iso #{shell_quote rev} -- #{shell_quote path}" 
+            cmd="#{GIT_BIN} --git-dir #{target('')} show --date=iso --pretty=fuller #{shell_quote rev} -- #{shell_quote path}" 
           else
             branch = shellout("#{GIT_BIN} --git-dir #{target('')} branch") { |io| io.grep(/\*/)[0].strip.match(/\* (.*)/)[1] }
-            cmd="#{GIT_BIN} --git-dir #{target('')} log --date=iso -1 #{branch} -- #{shell_quote path}" 
+            cmd="#{GIT_BIN} --git-dir #{target('')} log --date=iso --pretty=fuller -1 #{branch} -- #{shell_quote path}" 
           end
           rev=[]
           i=0
@@ -63,7 +63,7 @@ module Redmine
                 value = $2
                 if key == "Author"
                   changeset[:author] = value
-                elsif key == "Date"
+                elsif key == "CommitDate"
                   changeset[:date] = value
                 end
               elsif (parsing_descr == 0) && line.chomp.to_s == ""
@@ -96,7 +96,6 @@ module Redmine
           return rev
         end
 
-
         def info
           revs = revisions(url,nil,nil,{:limit => 1})
           if revs && revs.any?
@@ -138,7 +137,7 @@ module Redmine
         
         def revisions(path, identifier_from, identifier_to, options={})
           revisions = Revisions.new
-          cmd = "#{GIT_BIN} --git-dir #{target('')} log --raw --date=iso"
+          cmd = "#{GIT_BIN} --git-dir #{target('')} log --raw --date=iso --pretty=fuller"
           cmd << " --reverse" if options[:reverse]
           cmd << " -n #{options[:limit].to_i} " if (!options.nil?) && options[:limit]
           cmd << " #{shell_quote(identifier_from + '..')} " if identifier_from
@@ -177,7 +176,7 @@ module Redmine
                 value = $2
                 if key == "Author"
                   changeset[:author] = value
-                elsif key == "Date"
+                elsif key == "CommitDate"
                   changeset[:date] = value
                 end
               elsif (parsing_descr == 0) && line.chomp.to_s == ""
index 0098273be6e7b7e39d564b390cd96e27fdbcf684..da95d439f78d2d6286e5d15e696f65e86e390184 100644 (file)
@@ -36,7 +36,19 @@ class RepositoryGitTest < Test::Unit::TestCase
       
       assert_equal 6, @repository.changesets.count
       assert_equal 11, @repository.changes.count
-      assert_equal "Initial import.\nThe repository contains 3 files.", @repository.changesets.find(:first, :order => 'id ASC').comments
+      
+      commit = @repository.changesets.find(:first, :order => 'committed_on ASC')
+      assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments
+      assert_equal "jsmith <jsmith@foo.bar>", commit.committer
+      # TODO: add a commit with commit time <> author time to the test repository
+      assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on
+      assert_equal "2007-12-14".to_date, commit.commit_date
+      assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.revision
+      assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid
+      assert_equal 3, commit.changes.count
+      change = commit.changes.sort_by(&:path).first
+      assert_equal "README", change.path
+      assert_equal "A", change.action
     end
     
     def test_fetch_changesets_incremental