summaryrefslogtreecommitdiff
path: root/lib/gitlab/conflict
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-08-10 22:42:35 -0500
committerFatih Acet <acetfatih@gmail.com>2016-08-12 23:24:51 +0300
commit254dbad8f7c2213f87087858ff31a62f0d41a189 (patch)
tree8d9139176211c1e931e493953ff1998a4c65693c /lib/gitlab/conflict
parent83925ef45896e61ffbe92bbde34209a82d55427b (diff)
downloadgitlab-ce-254dbad8f7c2213f87087858ff31a62f0d41a189.tar.gz
Fix bug where conflict view would have one too many context sections
Diffstat (limited to 'lib/gitlab/conflict')
-rw-r--r--lib/gitlab/conflict/file.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/gitlab/conflict/file.rb b/lib/gitlab/conflict/file.rb
index 926b65d46fc..0a1fd27ced5 100644
--- a/lib/gitlab/conflict/file.rb
+++ b/lib/gitlab/conflict/file.rb
@@ -72,9 +72,11 @@ module Gitlab
def sections
return @sections if @sections
- chunked_lines = lines.chunk { |line| line.type.nil? }
+ chunked_lines = lines.chunk { |line| line.type.nil? }.to_a
match_line = nil
+ sections_count = chunked_lines.size
+
@sections = chunked_lines.flat_map.with_index do |(no_conflict, lines), i|
section = nil
@@ -82,7 +84,7 @@ module Gitlab
# always shown in full.
if no_conflict
conflict_before = i > 0
- conflict_after = chunked_lines.peek
+ conflict_after = (sections_count - i) > 1
if conflict_before && conflict_after
# Create a gap in a long context section.