Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
d09895a0
Commit
d09895a0
authored
Oct 12, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix diff parser so it tolerates to diff special markers in the content
parent
1e4b75ba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
lib/gitlab/diff/parser.rb
lib/gitlab/diff/parser.rb
+3
-1
spec/lib/gitlab/diff/parser_spec.rb
spec/lib/gitlab/diff/parser_spec.rb
+17
-0
No files found.
lib/gitlab/diff/parser.rb
View file @
d09895a0
...
@@ -17,7 +17,9 @@ module Gitlab
...
@@ -17,7 +17,9 @@ module Gitlab
# without having to instantiate all the others that come after it.
# without having to instantiate all the others that come after it.
Enumerator
.
new
do
|
yielder
|
Enumerator
.
new
do
|
yielder
|
@lines
.
each
do
|
line
|
@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
"
)
full_line
=
line
.
delete
(
"
\n
"
)
...
...
spec/lib/gitlab/diff/parser_spec.rb
View file @
d09895a0
...
@@ -143,4 +143,21 @@ eos
...
@@ -143,4 +143,21 @@ eos
it
{
expect
(
parser
.
parse
([])).
to
eq
([])
}
it
{
expect
(
parser
.
parse
([])).
to
eq
([])
}
it
{
expect
(
parser
.
parse
(
nil
)).
to
eq
([])
}
it
{
expect
(
parser
.
parse
(
nil
)).
to
eq
([])
}
end
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
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment