Commit 5f9d654939d388c7aeb8e84f6bb5b0d65319c535

Authored by Dmitriy Zaporozhets
1 parent ad5ea142

Dont show '0 additions and 0 deletions' message for commit

app/models/commit.rb
@@ -172,4 +172,10 @@ class Commit @@ -172,4 +172,10 @@ class Commit
172 lines.pop if lines.last == "-- " # end of diff 172 lines.pop if lines.last == "-- " # end of diff
173 lines.join("\n") 173 lines.join("\n")
174 end 174 end
  175 +
  176 + def has_zero_stats?
  177 + stats.total.zero?
  178 + rescue
  179 + true
  180 + end
175 end 181 end
app/views/commit/show.html.haml
1 = render "commit_box" 1 = render "commit_box"
2 2
3 -%p.pull-right.cgray  
4 - This commit has  
5 - %span.cgreen #{@commit.stats.additions} additions  
6 - and  
7 - %span.cred #{@commit.stats.deletions} deletions 3 +- unless @commit.has_zero_stats?
  4 + %p.pull-right.cgray
  5 + This commit has
  6 + %span.cgreen #{@commit.stats.additions} additions
  7 + and
  8 + %span.cred #{@commit.stats.deletions} deletions
8 9
9 = render "commits/diffs", diffs: @commit.diffs 10 = render "commits/diffs", diffs: @commit.diffs
10 = render "notes/notes_with_form" 11 = render "notes/notes_with_form"