From: Eric Davis Date: Sun, 26 Sep 2010 18:41:06 +0000 (+0000) Subject: Parse the timezone in #last_rev for git to correct display the Age diplay. #6346 X-Git-Tag: 1.1.0~326 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=319849caf8d269df386c01991b73a204db1018f5;p=redmine.git Parse the timezone in #last_rev for git to correct display the Age diplay. #6346 Contributed by Felix Schäfer git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4187 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb index 0857d9047..9a79bbb07 100644 --- a/lib/redmine/scm/adapters/git_adapter.rb +++ b/lib/redmine/scm/adapters/git_adapter.rb @@ -86,7 +86,7 @@ module Redmine def lastrev(path,rev) return nil if path.nil? - cmd = "#{GIT_BIN} --git-dir #{target('')} log --pretty=fuller --no-merges -n 1 " + cmd = "#{GIT_BIN} --git-dir #{target('')} log --date=iso --pretty=fuller --no-merges -n 1 " cmd << " #{shell_quote rev} " if rev cmd << "-- #{path} " unless path.empty? shellout(cmd) do |io| @@ -94,7 +94,7 @@ module Redmine id = io.gets.split[1] author = io.gets.match('Author:\s+(.*)$')[1] 2.times { io.gets } - time = io.gets.match('CommitDate:\s+(.*)$')[1] + time = Time.parse(io.gets.match('CommitDate:\s+(.*)$')[1]).localtime Revision.new({ :identifier => id, diff --git a/test/unit/lib/redmine/scm/adapters/git_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/git_adapter_test.rb index 6b716b9cd..f51d4a31f 100644 --- a/test/unit/lib/redmine/scm/adapters/git_adapter_test.rb +++ b/test/unit/lib/redmine/scm/adapters/git_adapter_test.rb @@ -29,6 +29,14 @@ class GitAdapterTest < ActiveSupport::TestCase assert_equal "jsmith", annotate.revisions[4].author end + def test_last_rev + last_rev = @adapter.lastrev("README", "4f26664364207fa8b1af9f8722647ab2d4ac5d43") + assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", last_rev.scmid + assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", last_rev.identifier + assert_equal "Adam Soltys ", last_rev.author + assert_equal "2009-06-24 05:27:38".to_time, last_rev.time + end + def test_annotate_moved_file annotate = @adapter.annotate('renamed_test.txt') assert_kind_of Redmine::Scm::Adapters::Annotate, annotate