Project

General

Profile

Feature #35432 » 0001-Git-View-annotate-prior-to-the-change.patch

Go MAEDA, 2022-09-03 09:35

View differences:

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 %>" data-txt="<%= 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 %>
<% if line == "\n" or line == "\r\n" %>
<td class="line-code"><br></td>
<% else %>
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 = ''
... This diff was truncated because it exceeds the maximum size that can be displayed.
(4-4/8)