Fixes #2740 - Signature detection fails if no signature range could be found.

This commit is contained in:
Ryan Lue 2019-10-11 17:10:41 +02:00 committed by Thorsten Eckel
parent adf4442648
commit 3107d684b5
2 changed files with 17 additions and 0 deletions

View file

@ -38,6 +38,8 @@ returns
.map { |head, tail| [head + 1, tail - 1] }
.find { |head, tail| tail > head + 4 }
next if sig_range.nil?
# Take up to 10 lines from this "gap" (i.e., the common substring)
match_content = diff_lines[sig_range.first..sig_range.last]
.map { |l| l.sub(/^./, '') }

View file

@ -90,6 +90,21 @@ RSpec.describe SignatureDetection do
end
end
end
context 'when input messages do not share 5-line common substrings' do
let(:messages) do
Array.new(2) { { content: <<~RAW, content_type: 'text/plain' } }
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Ut ut tincidunt nunc. Sed mattis aliquam tellus sit amet lacinia.
Mauris fermentum dictum aliquet.
Nam ex risus, gravida et ornare ut, mollis non sapien.
RAW
end
it 'doesnt break' do
expect { described_class.find_signature(messages) }.not_to raise_error
end
end
end
describe '.find_signature_line' do