Commit 85ec3451 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Prevent 500 error on git blame if empty file

parent 26befdc7
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
.tree-btn-group { .tree-btn-group {
.btn { .btn {
margin-right:-3px; margin-right: 0px;
padding: 2px 10px; padding: 2px 10px;
} }
} }
......
...@@ -8,5 +8,5 @@ ...@@ -8,5 +8,5 @@
- if current_page? project_blame_path(@project, @id) - if current_page? project_blame_path(@project, @id)
= link_to "normal view", project_blob_path(@project, @id), class: "btn btn-tiny" = link_to "normal view", project_blob_path(@project, @id), class: "btn btn-tiny"
- else - else
= link_to "blame", project_blame_path(@project, @id), class: "btn btn-tiny" = link_to "blame", project_blame_path(@project, @id), class: "btn btn-tiny" unless @blob.empty?
= link_to "history", project_commits_path(@project, @id), class: "btn btn-tiny" = link_to "history", project_commits_path(@project, @id), class: "btn btn-tiny"
...@@ -6,13 +6,14 @@ module Gitlab ...@@ -6,13 +6,14 @@ module Gitlab
def initialize(repository, sha, path) def initialize(repository, sha, path)
@repository, @sha, @path = repository, sha, path @repository, @sha, @path = repository, sha, path
end end
def each def each
raw_blame = Grit::Blob.blame(repository.repo, sha, path) raw_blame = Grit::Blob.blame(repository.repo, sha, path)
raw_blame.each do |commit, lines| raw_blame.each do |commit, lines|
next unless commit
commit = Gitlab::Git::Commit.new(commit) commit = Gitlab::Git::Commit.new(commit)
yield(commit, lines) yield(commit, lines)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment