Skip to content
Snippets Groups Projects
Commit b7a5125f authored by Martin Nowak's avatar Martin Nowak
Browse files

fix #39233 - 500 in merge request

- handle unchanged empty lines in inline diff
parent f1a98477
No related branches found
No related tags found
No related merge requests found
---
title: 'fix #39233 - 500 in merge request'
merge_request: 15774
author: Martin Nowak
type: fixed
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment