fix #39233 - 500 in merge request
- handle unchanged empty lines in inline diff
This commit is contained in:
parent
f1a9847701
commit
b7a5125f02
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: 'fix #39233 - 500 in merge request'
|
||||
merge_request: 15774
|
||||
author: Martin Nowak
|
||||
type: fixed
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue