Commit 85ec34518318cf40f2a0c5ef60398e0225e691c1

Authored by Dmitriy Zaporozhets
1 parent 26befdc7

Prevent 500 error on git blame if empty file

app/assets/stylesheets/sections/tree.scss
... ... @@ -97,7 +97,7 @@
97 97  
98 98 .tree-btn-group {
99 99 .btn {
100   - margin-right:-3px;
  100 + margin-right: 0px;
101 101 padding: 2px 10px;
102 102 }
103 103 }
... ...
app/views/blob/_actions.html.haml
... ... @@ -8,5 +8,5 @@
8 8 - if current_page? project_blame_path(@project, @id)
9 9 = link_to "normal view", project_blob_path(@project, @id), class: "btn btn-tiny"
10 10 - else
11   - = link_to "blame", project_blame_path(@project, @id), class: "btn btn-tiny"
  11 + = link_to "blame", project_blame_path(@project, @id), class: "btn btn-tiny" unless @blob.empty?
12 12 = link_to "history", project_commits_path(@project, @id), class: "btn btn-tiny"
... ...
lib/gitlab/git/blame.rb
... ... @@ -6,13 +6,14 @@ module Gitlab
6 6  
7 7 def initialize(repository, sha, path)
8 8 @repository, @sha, @path = repository, sha, path
9   -
10 9 end
11 10  
12 11 def each
13 12 raw_blame = Grit::Blob.blame(repository.repo, sha, path)
14 13  
15 14 raw_blame.each do |commit, lines|
  15 + next unless commit
  16 +
16 17 commit = Gitlab::Git::Commit.new(commit)
17 18 yield(commit, lines)
18 19 end
... ...