OSDN Git Service

Prevent 500 error on git blame if empty file
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Thu, 18 Apr 2013 09:46:41 +0000 (12:46 +0300)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Thu, 18 Apr 2013 09:46:41 +0000 (12:46 +0300)
app/assets/stylesheets/sections/tree.scss
app/views/blob/_actions.html.haml
lib/gitlab/git/blame.rb

index def440c..ffde6aa 100644 (file)
@@ -97,7 +97,7 @@
 
 .tree-btn-group {
   .btn {
-    margin-right:-3px;
+    margin-right: 0px;
     padding: 2px 10px;
   }
 }
index 1da39e7..456c743 100644 (file)
@@ -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"
index d6e988b..d7282c5 100644 (file)
@@ -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