Skip to content
Snippets Groups Projects
Commit 85ec3451 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Prevent 500 error on git blame if empty file

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