@@ -235,14 +235,15 module Redmine | |||||
235 | # git annotates binary files |
|
235 | # git annotates binary files | |
236 | return nil if content.is_binary_data? |
|
236 | return nil if content.is_binary_data? | |
237 | identifier = '' |
|
237 | identifier = '' | |
238 | author = '' |
|
238 | # git shows commit author on the first occurrence only | |
|
239 | authors_by_commit = {} | |||
239 | content.split("\n").each do |line| |
|
240 | content.split("\n").each do |line| | |
240 | if line =~ /^([0-9a-f]{39,40})\s.*/ |
|
241 | if line =~ /^([0-9a-f]{39,40})\s.*/ | |
241 | identifier = $1 |
|
242 | identifier = $1 | |
242 | elsif line =~ /^author (.+)/ |
|
243 | elsif line =~ /^author (.+)/ | |
243 | author = $1.strip |
|
244 | authors_by_commit[identifier] = $1.strip | |
244 | elsif line =~ /^\t(.*)/ |
|
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 | identifier = '' |
|
247 | identifier = '' | |
247 | author = '' |
|
248 | author = '' | |
248 | end |
|
249 | end |
@@ -20,14 +20,15 class GitAdapterTest < ActiveSupport::TestCase | |||||
20 | annotate = @adapter.annotate('sources/watchers_controller.rb') |
|
20 | annotate = @adapter.annotate('sources/watchers_controller.rb') | |
21 | assert_kind_of Redmine::Scm::Adapters::Annotate, annotate |
|
21 | assert_kind_of Redmine::Scm::Adapters::Annotate, annotate | |
22 | assert_equal 41, annotate.lines.size |
|
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 | end |
|
26 | end | |
24 |
|
27 | |||
25 | def test_annotate_moved_file |
|
28 | def test_annotate_moved_file | |
26 | annotate = @adapter.annotate('renamed_test.txt') |
|
29 | annotate = @adapter.annotate('renamed_test.txt') | |
27 | assert_kind_of Redmine::Scm::Adapters::Annotate, annotate |
|
30 | assert_kind_of Redmine::Scm::Adapters::Annotate, annotate | |
28 | assert_equal 2, annotate.lines.size |
|
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 | end |
|
32 | end | |
32 | else |
|
33 | else | |
33 | puts "Git test repository NOT FOUND. Skipping unit tests !!!" |
|
34 | puts "Git test repository NOT FOUND. Skipping unit tests !!!" |
General Comments 0
You need to be logged in to leave comments.
Login now