Skip to content

Commit

Permalink
Fixes a timezone problem with #last_rev in the git adapter. #6346
Browse files Browse the repository at this point in the history
Contributed by Felix Schäfer
  • Loading branch information
thegcat committed Sep 19, 2010
1 parent bd193a0 commit f8c7ce4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/redmine/scm/adapters/git_adapter.rb
Expand Up @@ -86,15 +86,15 @@ def entries(path=nil, identifier=nil)

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|
begin
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,
Expand Down
8 changes: 8 additions & 0 deletions test/unit/lib/redmine/scm/adapters/git_adapter_test.rb
Expand Up @@ -29,6 +29,14 @@ def test_annotate
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 <asoltys@gmail.com>", 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
Expand Down

0 comments on commit f8c7ce4

Please sign in to comment.