BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
parser.rb
lib/gitlab/diff/parser.rb
+3
-1
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
# 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
"
)
...
...
spec/lib/gitlab/diff/parser_spec.rb
View file @
d09895a0
...
...
@@ -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
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