Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRubén Dávila <rdavila84@gmail.com>2016-01-09 09:55:31 +0300
committerRubén Dávila <rdavila84@gmail.com>2016-01-09 09:55:31 +0300
commitfed10766e533fcef2a6840deeb8d7ea1747f0c72 (patch)
tree1cf95deab1064dfb9c9ddd4dbca563c2b26f6f79 /lib/gitlab/diff
parent164c6374a708754086a1bca1033c46c01503056d (diff)
Fix broken spec for submodule commit. #3945
Diffstat (limited to 'lib/gitlab/diff')
-rw-r--r--lib/gitlab/diff/highlight.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/gitlab/diff/highlight.rb b/lib/gitlab/diff/highlight.rb
index caeefe5bbdd..3c44abff3fb 100644
--- a/lib/gitlab/diff/highlight.rb
+++ b/lib/gitlab/diff/highlight.rb
@@ -85,10 +85,14 @@ module Gitlab
case diff_line.type
when 'new', nil
- diff_line.text = new_lines[diff_line.new_pos - 1].try(:gsub!, /\A\s/, line_prefix)
+ line = new_lines[diff_line.new_pos - 1]
when 'old'
- diff_line.text = old_lines[diff_line.old_pos - 1].try(:gsub!, /\A\s/, line_prefix)
+ line = old_lines[diff_line.old_pos - 1]
end
+
+ # Only update text if line is found. This will prevent
+ # issues with submodules given the line only exists in diff content.
+ diff_line.text = line.gsub!(/\A\s/, line_prefix) if line
end
@lines
@@ -121,6 +125,10 @@ module Gitlab
lines.map! { |line| " #{line}" }
end
end
+
+ def submodules
+ @submodules ||= diff_repository.raw_repository.submodules(diff_new_ref).keys
+ end
end
end
end