summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2017-08-22 16:27:09 +0100
committerSean McGivern <sean@gitlab.com>2017-08-24 11:11:18 +0100
commite8525e107da9234d743caf8a0c7db1f46af60e89 (patch)
tree75be1e6d69d9049d976d41699dec4e62b5cfeb4e /lib
parentb0f09406f50882c7e085c2a9b853be5dcf3d79dd (diff)
downloadgitlab-ce-e8525e107da9234d743caf8a0c7db1f46af60e89.tar.gz
Show un-highlighted diffs when blobs are the same
For some old merge requests, we don't have enough information to figure out the old blob and the new blob for the file. This means that we can't highlight the diff correctly, but we can still display it without highlighting.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/diff/file.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/gitlab/diff/file.rb b/lib/gitlab/diff/file.rb
index 17a9ec01637..1dabd4ebdd0 100644
--- a/lib/gitlab/diff/file.rb
+++ b/lib/gitlab/diff/file.rb
@@ -186,7 +186,10 @@ module Gitlab
end
def content_changed?
- old_blob && new_blob && old_blob.id != new_blob.id
+ return blobs_changed? if diff_refs
+ return false if new_file? || deleted_file? || renamed_file?
+
+ text? && diff_lines.any?
end
def different_type?
@@ -225,6 +228,10 @@ module Gitlab
private
+ def blobs_changed?
+ old_blob && new_blob && old_blob.id != new_blob.id
+ end
+
def simple_viewer_class
return DiffViewer::NotDiffable unless diffable?