Feature #35432 » 35432.patch
app/views/repositories/annotate.html.erb | ||
---|---|---|
16 | 16 |
<% line_num = 1; previous_revision = nil %> |
17 | 17 |
<% syntax_highlight_lines(@path, Redmine::CodesetUtil.to_utf8_by_setting(@annotate.content)).each do |line| %> |
18 | 18 |
<% revision = @annotate.revisions[line_num - 1] %> |
19 |
<% prior = @annotate.priors[line_num - 1] %> |
|
19 | 20 |
<tr id="L<%= line_num %>" class="bloc-<%= revision.nil? ? 0 : colors[revision.identifier || revision.revision] %> <%= previous_revision && revision && revision != previous_revision ? 'bloc-change' : nil%>"> |
20 | 21 |
<th class="line-num"><a href="#L<%= line_num %>"><%= line_num %></a></th> |
21 | 22 |
<td class="revision"> |
... | ... | |
31 | 32 |
<%= author.split('<').first %> |
32 | 33 |
<% end %> |
33 | 34 |
</td> |
35 |
<% if @repository.is_a?(Repository::Git) %> |
|
36 |
<td class="prior"> |
|
37 |
<% if revision && revision != previous_revision && prior %> |
|
38 |
<%= link_to '', {:action => 'annotate', :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(prior.split[1] || @path), :rev => prior.split[0] }, :title => l(:label_view_prior_revision), :class => 'icon icon-history' %> |
|
39 |
<% end %> |
|
40 |
</td> |
|
41 |
<% end %> |
|
34 | 42 |
<td class="line-code"><pre><%= line.html_safe %></pre></td> |
35 | 43 |
</tr> |
36 | 44 |
<% line_num += 1; previous_revision = revision %> |
config/locales/en.yml | ||
---|---|---|
830 | 830 |
label_latest_revision_plural: Latest revisions |
831 | 831 |
label_view_revisions: View revisions |
832 | 832 |
label_view_all_revisions: View all revisions |
833 |
label_view_prior_revision: View prior to this change |
|
833 | 834 |
label_x_revisions: "%{count} revisions" |
834 | 835 |
label_max_size: Maximum size |
835 | 836 |
label_sort_highest: Move to top |
lib/redmine/scm/adapters/abstract_adapter.rb | ||
---|---|---|
410 | 410 |
end |
411 | 411 | |
412 | 412 |
class Annotate |
413 |
attr_reader :lines, :revisions |
|
413 |
attr_reader :lines, :revisions, :priors
|
|
414 | 414 | |
415 | 415 |
def initialize |
416 | 416 |
@lines = [] |
417 | 417 |
@revisions = [] |
418 |
@priors = [] |
|
418 | 419 |
end |
419 | 420 | |
420 |
def add_line(line, revision) |
|
421 |
def add_line(line, revision, prior=nil)
|
|
421 | 422 |
@lines << line |
422 | 423 |
@revisions << revision |
424 |
@priors << prior |
|
423 | 425 |
end |
424 | 426 | |
425 | 427 |
def content |
lib/redmine/scm/adapters/git_adapter.rb | ||
---|---|---|
381 | 381 |
identifier = '' |
382 | 382 |
# git shows commit author on the first occurrence only |
383 | 383 |
authors_by_commit = {} |
384 |
prior_by_commit = {} |
|
384 | 385 |
content.split("\n").each do |line| |
385 | 386 |
if line =~ /^([0-9a-f]{39,40})\s.*/ |
386 | 387 |
identifier = $1 |
387 | 388 |
elsif line =~ /^author (.+)/ |
388 | 389 |
authors_by_commit[identifier] = $1.strip |
390 |
elsif line =~ /^previous (.+)/ |
|
391 |
prior_by_commit[identifier] = $1.strip |
|
389 | 392 |
elsif line =~ /^\t(.*)/ |
390 | 393 |
blame.add_line( |
391 | 394 |
$1, |
... | ... | |
393 | 396 |
:identifier => identifier, |
394 | 397 |
:revision => identifier, |
395 | 398 |
:scmid => identifier, |
396 |
:author => authors_by_commit[identifier] |
|
397 |
) |
|
399 |
:author => authors_by_commit[identifier], |
|
400 |
), |
|
401 |
prior_by_commit[identifier] |
|
398 | 402 |
) |
399 | 403 |
identifier = '' |
400 | 404 |
author = '' |
public/stylesheets/scm.css | ||
---|---|---|
98 | 98 |
width: 2%; |
99 | 99 |
padding-left: 1em; |
100 | 100 |
background: inherit; |
101 |
text-align: left; |
|
101 | 102 |
} |
102 | 103 | |
103 | 104 |
table.annotate td.author { |
test/functional/repositories_git_controller_test.rb | ||
---|---|---|
588 | 588 |
assert_response :success |
589 | 589 | |
590 | 590 |
# Line 23, changeset 2f9c0091 |
591 |
prior_rev, prior_path = '4a79347ea4b7184938d9bbea0fd421a6079f71bb' ,'sources/watchers_controller.rb' |
|
591 | 592 |
assert_select 'tr' do |
592 | 593 |
assert_select 'th.line-num', :text => '23' |
593 | 594 |
assert_select 'td.revision', :text => /2f9c0091/ |
594 | 595 |
assert_select 'td.author', :text => 'jsmith' |
596 |
assert_select 'td.prior' do |
|
597 |
assert_select 'a.icon-history[href=?]', |
|
598 |
"/projects/subproject1/repository/#{@repository.id}/revisions/#{prior_rev}/annotate/#{prior_path}" |
|
599 |
end |
|
595 | 600 |
assert_select 'td', :text => /remove_watcher/ |
596 | 601 |
end |
597 | 602 |
end |
test/unit/lib/redmine/scm/adapters/git_adapter_test.rb | ||
---|---|---|
437 | 437 |
assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", |
438 | 438 |
annotate.revisions[4].identifier |
439 | 439 |
assert_equal "jsmith", annotate.revisions[4].author |
440 |
assert_equal "4a79347ea4b7184938d9bbea0fd421a6079f71bb", |
|
441 |
annotate.priors[22].split[0] |
|
442 |
assert_equal "sources/watchers_controller.rb", |
|
443 |
annotate.priors[22].split[1] |
|
440 | 444 |
end |
441 | 445 | |
442 | 446 |
def test_annotate_latin_1_identifier |