Feature #35432 » 35432.patch
| app/views/repositories/annotate.html.erb | ||
|---|---|---|
|
<% line_num = 1; previous_revision = nil %>
|
||
|
<% syntax_highlight_lines(@path, Redmine::CodesetUtil.to_utf8_by_setting(@annotate.content)).each do |line| %>
|
||
|
<% revision = @annotate.revisions[line_num - 1] %>
|
||
|
<% prior = @annotate.priors[line_num - 1] %>
|
||
|
<tr id="L<%= line_num %>" class="bloc-<%= revision.nil? ? 0 : colors[revision.identifier || revision.revision] %> <%= previous_revision && revision && revision != previous_revision ? 'bloc-change' : nil%>">
|
||
|
<th class="line-num"><a href="#L<%= line_num %>"><%= line_num %></a></th>
|
||
|
<td class="revision">
|
||
| ... | ... | |
|
<%= author.split('<').first %>
|
||
|
<% end %>
|
||
|
</td>
|
||
|
<% if @repository.is_a?(Repository::Git) %>
|
||
|
<td class="prior">
|
||
|
<% if revision && revision != previous_revision && prior %>
|
||
|
<%= 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' %>
|
||
|
<% end %>
|
||
|
</td>
|
||
|
<% end %>
|
||
|
<td class="line-code"><pre><%= line.html_safe %></pre></td>
|
||
|
</tr>
|
||
|
<% line_num += 1; previous_revision = revision %>
|
||
| config/locales/en.yml | ||
|---|---|---|
|
label_latest_revision_plural: Latest revisions
|
||
|
label_view_revisions: View revisions
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_view_prior_revision: View prior to this change
|
||
|
label_x_revisions: "%{count} revisions"
|
||
|
label_max_size: Maximum size
|
||
|
label_sort_highest: Move to top
|
||
| lib/redmine/scm/adapters/abstract_adapter.rb | ||
|---|---|---|
|
end
|
||
|
class Annotate
|
||
|
attr_reader :lines, :revisions
|
||
|
attr_reader :lines, :revisions, :priors
|
||
|
def initialize
|
||
|
@lines = []
|
||
|
@revisions = []
|
||
|
@priors = []
|
||
|
end
|
||
|
def add_line(line, revision)
|
||
|
def add_line(line, revision, prior=nil)
|
||
|
@lines << line
|
||
|
@revisions << revision
|
||
|
@priors << prior
|
||
|
end
|
||
|
def content
|
||
| lib/redmine/scm/adapters/git_adapter.rb | ||
|---|---|---|
|
identifier = ''
|
||
|
# git shows commit author on the first occurrence only
|
||
|
authors_by_commit = {}
|
||
|
prior_by_commit = {}
|
||
|
content.split("\n").each do |line|
|
||
|
if line =~ /^([0-9a-f]{39,40})\s.*/
|
||
|
identifier = $1
|
||
|
elsif line =~ /^author (.+)/
|
||
|
authors_by_commit[identifier] = $1.strip
|
||
|
elsif line =~ /^previous (.+)/
|
||
|
prior_by_commit[identifier] = $1.strip
|
||
|
elsif line =~ /^\t(.*)/
|
||
|
blame.add_line(
|
||
|
$1,
|
||
| ... | ... | |
|
:identifier => identifier,
|
||
|
:revision => identifier,
|
||
|
:scmid => identifier,
|
||
|
:author => authors_by_commit[identifier]
|
||
|
)
|
||
|
:author => authors_by_commit[identifier],
|
||
|
),
|
||
|
prior_by_commit[identifier]
|
||
|
)
|
||
|
identifier = ''
|
||
|
author = ''
|
||
| public/stylesheets/scm.css | ||
|---|---|---|
|
width: 2%;
|
||
|
padding-left: 1em;
|
||
|
background: inherit;
|
||
|
text-align: left;
|
||
|
}
|
||
|
table.annotate td.author {
|
||
| test/functional/repositories_git_controller_test.rb | ||
|---|---|---|
|
assert_response :success
|
||
|
# Line 23, changeset 2f9c0091
|
||
|
prior_rev, prior_path = '4a79347ea4b7184938d9bbea0fd421a6079f71bb' ,'sources/watchers_controller.rb'
|
||
|
assert_select 'tr' do
|
||
|
assert_select 'th.line-num', :text => '23'
|
||
|
assert_select 'td.revision', :text => /2f9c0091/
|
||
|
assert_select 'td.author', :text => 'jsmith'
|
||
|
assert_select 'td.prior' do
|
||
|
assert_select 'a.icon-history[href=?]',
|
||
|
"/projects/subproject1/repository/#{@repository.id}/revisions/#{prior_rev}/annotate/#{prior_path}"
|
||
|
end
|
||
|
assert_select 'td', :text => /remove_watcher/
|
||
|
end
|
||
|
end
|
||
| test/unit/lib/redmine/scm/adapters/git_adapter_test.rb | ||
|---|---|---|
|
assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518",
|
||
|
annotate.revisions[4].identifier
|
||
|
assert_equal "jsmith", annotate.revisions[4].author
|
||
|
assert_equal "4a79347ea4b7184938d9bbea0fd421a6079f71bb",
|
||
|
annotate.priors[22].split[0]
|
||
|
assert_equal "sources/watchers_controller.rb",
|
||
|
annotate.priors[22].split[1]
|
||
|
end
|
||
|
def test_annotate_latin_1_identifier
|
||