##// END OF EJS Templates
Fixes git annotate (#3832)....
Jean-Philippe Lang -
r3417:3355ffe029fd
parent child
Show More
@@ -235,14 +235,15 module Redmine
235 235 # git annotates binary files
236 236 return nil if content.is_binary_data?
237 237 identifier = ''
238 author = ''
238 # git shows commit author on the first occurrence only
239 authors_by_commit = {}
239 240 content.split("\n").each do |line|
240 241 if line =~ /^([0-9a-f]{39,40})\s.*/
241 242 identifier = $1
242 243 elsif line =~ /^author (.+)/
243 author = $1.strip
244 authors_by_commit[identifier] = $1.strip
244 245 elsif line =~ /^\t(.*)/
245 blame.add_line($1, Revision.new(:identifier => identifier, :author => author))
246 blame.add_line($1, Revision.new(:identifier => identifier, :author => authors_by_commit[identifier]))
246 247 identifier = ''
247 248 author = ''
248 249 end
@@ -20,14 +20,15 class GitAdapterTest < ActiveSupport::TestCase
20 20 annotate = @adapter.annotate('sources/watchers_controller.rb')
21 21 assert_kind_of Redmine::Scm::Adapters::Annotate, annotate
22 22 assert_equal 41, annotate.lines.size
23 assert_equal "# This program is free software; you can redistribute it and/or", annotate.lines[4].strip
24 assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", annotate.revisions[4].identifier
25 assert_equal "jsmith", annotate.revisions[4].author
23 26 end
24 27
25 28 def test_annotate_moved_file
26 29 annotate = @adapter.annotate('renamed_test.txt')
27 30 assert_kind_of Redmine::Scm::Adapters::Annotate, annotate
28 31 assert_equal 2, annotate.lines.size
29 assert_equal "Let's pretend I'm adding a new feature!", annotate.lines.second
30 assert_equal "7e61ac704deecde634b51e59daa8110435dcb3da", annotate.revisions.second.identifier
31 32 end
32 33 else
33 34 puts "Git test repository NOT FOUND. Skipping unit tests !!!"
General Comments 0
You need to be logged in to leave comments. Login now