Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-01-28 16:49:21 +0300
committerDouwe Maan <douwe@selenight.nl>2016-01-28 16:49:21 +0300
commitb636f83e5910d10a954464370efe42cc14a097ba (patch)
tree25576ef4d66cff8d40cba4004302a178bfc2ec4e /app
parent4be80f8aa3c585882b4499d6d69dcbf4a97eff29 (diff)
Move blame group logic to dedicated class
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects/blame_controller.rb28
-rw-r--r--app/views/projects/blame/show.html.haml4
2 files changed, 3 insertions, 29 deletions
diff --git a/app/controllers/projects/blame_controller.rb b/app/controllers/projects/blame_controller.rb
index d2aee3879e9..f576d0be1fc 100644
--- a/app/controllers/projects/blame_controller.rb
+++ b/app/controllers/projects/blame_controller.rb
@@ -8,32 +8,6 @@ class Projects::BlameController < Projects::ApplicationController
def show
@blob = @repository.blob_at(@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
-
- highlighted_lines = Gitlab::Highlight.highlight(@blob.name, @blob.data).lines
- i = 0
- blame.each do |commit, line|
- line = highlighted_lines[i].html_safe
- 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
- i += 1
- end
-
- groups << current_group if current_group.present?
- groups
+ @blame_groups = Gitlab::Blame.new(@blob, @commit).groups
end
end
diff --git a/app/views/projects/blame/show.html.haml b/app/views/projects/blame/show.html.haml
index aecdec32d00..eb6fbfaffa0 100644
--- a/app/views/projects/blame/show.html.haml
+++ b/app/views/projects/blame/show.html.haml
@@ -15,11 +15,11 @@
.file-content.blame.code.js-syntax-highlight
%table
- current_line = 1
- - @blame.each do |blame_group|
+ - @blame_groups.each do |blame_group|
%tr
%td.blame-commit
.commit
- - commit = Commit.new(blame_group[:commit], @project)
+ - commit = blame_group[:commit]
.commit-row-title
%strong
= link_to_gfm truncate(commit.title, length: 35), namespace_project_commit_path(@project.namespace, @project, commit.id), class: "cdark"