提交 3a7623fc 编写于 作者: S Sean McGivern

Merge branch 'fix_diff_parsing' into 'master'

Fix diff parser so it tolerates to diff special markers in the content

Closes #34431

See merge request gitlab-org/gitlab-ce!14848
---
title: Fix diff parser so it tolerates to diff special markers in the content
merge_request:
author:
type: fixed
......@@ -17,7 +17,9 @@ module Gitlab
# without having to instantiate all the others that come after it.
Enumerator.new do |yielder|
@lines.each do |line|
next if filename?(line)
# We're expecting a filename parameter only in a meta-part of the diff content
# when type is defined then we're already in a content-part
next if filename?(line) && type.nil?
full_line = line.delete("\n")
......
......@@ -143,4 +143,21 @@ eos
it { expect(parser.parse([])).to eq([]) }
it { expect(parser.parse(nil)).to eq([]) }
end
describe 'tolerates special diff markers in a content' do
it "counts lines correctly" do
diff = <<~END
--- a/test
+++ b/test
@@ -1,2 +1,2 @@
+ipsum
+++ b
-ipsum
END
lines = parser.parse(diff.lines).to_a
expect(lines.size).to eq(3)
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册