fix #39233 - 500 in merge request

- handle unchanged empty lines in inline diff
This commit is contained in:
Martin Nowak 2017-12-06 19:10:53 +01:00
parent f1a9847701
commit b7a5125f02
3 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
title: 'fix #39233 - 500 in merge request'
merge_request: 15774
author: Martin Nowak
type: fixed

View File

@ -70,7 +70,7 @@ module Gitlab
def find_changed_line_pairs(lines)
# Prefixes of all diff lines, indicating their types
# For example: `" - + -+ ---+++ --+ -++"`
line_prefixes = lines.each_with_object("") { |line, s| s << line[0] }.gsub(/[^ +-]/, ' ')
line_prefixes = lines.each_with_object("") { |line, s| s << (line[0] || ' ') }.gsub(/[^ +-]/, ' ')
changed_line_pairs = []
line_prefixes.scan(LINE_PAIRS_PATTERN) do

View File

@ -31,6 +31,10 @@ describe Gitlab::Diff::InlineDiff do
expect(subject[7]).to eq([17..17])
expect(subject[8]).to be_nil
end
it 'can handle unchanged empty lines' do
expect { described_class.for_lines(['- bar', '+ baz', '']) }.not_to raise_error
end
end
describe "#inline_diffs" do