Fixes #2740 - Signature detection fails if no signature range could be found.
This commit is contained in:
parent
adf4442648
commit
3107d684b5
2 changed files with 17 additions and 0 deletions
|
@ -38,6 +38,8 @@ returns
|
||||||
.map { |head, tail| [head + 1, tail - 1] }
|
.map { |head, tail| [head + 1, tail - 1] }
|
||||||
.find { |head, tail| tail > head + 4 }
|
.find { |head, tail| tail > head + 4 }
|
||||||
|
|
||||||
|
next if sig_range.nil?
|
||||||
|
|
||||||
# Take up to 10 lines from this "gap" (i.e., the common substring)
|
# Take up to 10 lines from this "gap" (i.e., the common substring)
|
||||||
match_content = diff_lines[sig_range.first..sig_range.last]
|
match_content = diff_lines[sig_range.first..sig_range.last]
|
||||||
.map { |l| l.sub(/^./, '') }
|
.map { |l| l.sub(/^./, '') }
|
||||||
|
|
|
@ -90,6 +90,21 @@ RSpec.describe SignatureDetection do
|
||||||
end
|
end
|
||||||
end
|
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 'doesn’t break' do
|
||||||
|
expect { described_class.find_signature(messages) }.not_to raise_error
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.find_signature_line' do
|
describe '.find_signature_line' do
|
||||||
|
|
Loading…
Reference in a new issue