mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-11 21:56:19 +10:00
@@ -8,6 +8,28 @@ class Projects::BlameController < Projects::ApplicationController
|
||||
|
||||
def show
|
||||
@blob = @repository.blob_at(@commit.id, @path)
|
||||
@blame = Gitlab::Git::Blame.new(@repository, @commit.id, @path)
|
||||
@blame = group_blame_lines
|
||||
end
|
||||
|
||||
def group_blame_lines
|
||||
blame = Gitlab::Git::Blame.new(@repository, @commit.id, @path)
|
||||
|
||||
prev_sha = nil
|
||||
groups = []
|
||||
current_group = nil
|
||||
|
||||
blame.each do |commit, line|
|
||||
if prev_sha && prev_sha == commit.sha
|
||||
current_group[:lines] << line
|
||||
else
|
||||
groups << current_group if current_group.present?
|
||||
current_group = { commit: commit, lines: [line] }
|
||||
end
|
||||
|
||||
prev_sha = commit.sha
|
||||
end
|
||||
|
||||
groups << current_group if current_group.present?
|
||||
groups
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,30 +13,32 @@
|
||||
.file-content.blame.highlight
|
||||
%table
|
||||
- current_line = 1
|
||||
- @blame.each do |raw_commit, line|
|
||||
- @blame.each do |blame_group|
|
||||
%tr
|
||||
%td.blame-commit
|
||||
.commit
|
||||
- unless @prev_commit && @prev_commit.sha == raw_commit.sha
|
||||
- commit = Commit.new(raw_commit, @project)
|
||||
.commit-row-title
|
||||
%strong
|
||||
= link_to_gfm truncate(commit.title, length: 35), namespace_project_commit_path(@project.namespace, @project, commit.id), class: "cdark"
|
||||
.pull-right
|
||||
= link_to commit.short_id, namespace_project_commit_path(@project.namespace, @project, commit), class: "monospace"
|
||||
|
||||
.light
|
||||
= commit_author_link(commit, avatar: false)
|
||||
authored
|
||||
#{time_ago_with_tooltip(commit.committed_date)}
|
||||
- @prev_commit = raw_commit
|
||||
- commit = Commit.new(blame_group[:commit], @project)
|
||||
.commit-row-title
|
||||
%strong
|
||||
= link_to_gfm truncate(commit.title, length: 35), namespace_project_commit_path(@project.namespace, @project, commit.id), class: "cdark"
|
||||
.pull-right
|
||||
= link_to commit.short_id, namespace_project_commit_path(@project.namespace, @project, commit), class: "monospace"
|
||||
|
||||
.light
|
||||
= commit_author_link(commit, avatar: false)
|
||||
authored
|
||||
#{time_ago_with_tooltip(commit.committed_date)}
|
||||
%td.lines.blame-numbers
|
||||
%pre
|
||||
= current_line
|
||||
- current_line += 1
|
||||
- line_count = blame_group[:lines].count
|
||||
- (current_line...(current_line + line_count)).each do |i|
|
||||
= i
|
||||
\
|
||||
- current_line += line_count
|
||||
%td.lines
|
||||
%pre{class: 'code highlight white'}
|
||||
%code
|
||||
:erb
|
||||
<%= highlight(@blob.name, line, nowrap: true, continue: true).html_safe %>
|
||||
- blame_group[:lines].each do |line|
|
||||
:erb
|
||||
<%= highlight(@blob.name, line, nowrap: true, continue: true).html_safe %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user