From d29bb23a6896c1c660fe27d1a9bd5dbfde94bf52 Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Sat, 14 Jun 2014 22:54:56 +0300
Subject: [PATCH] Update gitlab-grit to newer version with normal diff
 collection. Show if file mode was changed

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
---
 Gemfile.lock                                    |  2 +-
 app/assets/stylesheets/sections/diff.scss       | 11 +++++++----
 app/helpers/commits_helper.rb                   |  4 ++++
 app/views/projects/commits/_diffs.html.haml     |  3 +--
 app/views/projects/commits/_text_file.html.haml |  3 +++
 5 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/Gemfile.lock b/Gemfile.lock
index 896e6fdebea..a9a23f74395 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -164,7 +164,7 @@ GEM
       multi_json
     gitlab-grack (2.0.0.pre)
       rack (~> 1.5.1)
-    gitlab-grit (2.6.8)
+    gitlab-grit (2.6.9)
       charlock_holmes (~> 0.6)
       diff-lcs (~> 1.1)
       mime-types (~> 1.15)
diff --git a/app/assets/stylesheets/sections/diff.scss b/app/assets/stylesheets/sections/diff.scss
index 24d997c9fca..f4926e2f523 100644
--- a/app/assets/stylesheets/sections/diff.scss
+++ b/app/assets/stylesheets/sections/diff.scss
@@ -11,7 +11,6 @@
 
     > span {
       font-family: $monospace_font;
-      font-size: 14px;
       line-height: 2;
     }
 
@@ -19,9 +18,7 @@
       float: right;
 
       .btn {
-        background-color: #EEE;
-        color: #666;
-        font-weight: bolder;
+        background-color: #FFF;
       }
     }
 
@@ -32,6 +29,7 @@
 
     .file-mode {
       font-family: $monospace_font;
+      margin-left: 10px;
     }
   }
   .diff-content {
@@ -51,6 +49,11 @@
       }
     }
 
+    .file-mode-changed {
+      padding: 10px;
+      color: #777;
+    }
+
     table {
       width: 100%;
       font-family: $monospace_font;
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb
index 62aa6832371..4d27cf2851e 100644
--- a/app/helpers/commits_helper.rb
+++ b/app/helpers/commits_helper.rb
@@ -216,4 +216,8 @@ module CommitsHelper
       link_to(text.html_safe, user_path(user), options)
     end
   end
+
+  def diff_file_mode_changed?(diff)
+    diff.a_mode && diff.b_mode && diff.a_mode != diff.b_mode
+  end
 end
diff --git a/app/views/projects/commits/_diffs.html.haml b/app/views/projects/commits/_diffs.html.haml
index 3d7b5974144..a62f50776fa 100644
--- a/app/views/projects/commits/_diffs.html.haml
+++ b/app/views/projects/commits/_diffs.html.haml
@@ -42,7 +42,6 @@
 .files
   - unless @suppress_diff
     - diffs.each_with_index do |diff, i|
-      - next if diff.diff.empty?
       - file = project.repository.blob_at(@commit.id, diff.new_path)
       - file = project.repository.blob_at(@commit.parent_id, diff.old_path) unless file
       - next unless file
@@ -58,7 +57,7 @@
                   %span.commit-short-id= @commit.short_id(6)
           - else
             %span= diff.new_path
-            - if diff.a_mode && diff.b_mode && diff.a_mode != diff.b_mode
+            - if diff_file_mode_changed?(diff)
               %span.file-mode= "#{diff.a_mode} → #{diff.b_mode}"
 
             .diff-btn-group
diff --git a/app/views/projects/commits/_text_file.html.haml b/app/views/projects/commits/_text_file.html.haml
index 74a68b1bf82..8ced4133294 100644
--- a/app/views/projects/commits/_text_file.html.haml
+++ b/app/views/projects/commits/_text_file.html.haml
@@ -22,3 +22,6 @@
       - unless comments.empty?
         = render "projects/notes/diff_notes_with_reply", notes: comments, line: line
 
+- if diff.diff.blank? && diff_file_mode_changed?(diff)
+  .file-mode-changed
+    File mode changed
-- 
GitLab