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
1c40f18f
Commit
1c40f18f
authored
Apr 02, 2018
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'sh-cleanup-crlf-gitmodules' into 'master'
Handle CR-LFs properly in .gitmodules file Closes #2262 See merge request gitlab-org/gitlab-ce!18117
parents
aec23eaa
6fd1d07c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
gitmodules_parser.rb
lib/gitlab/git/gitmodules_parser.rb
+3
-1
gitmodules_parser_spec.rb
spec/lib/gitlab/git/gitmodules_parser_spec.rb
+2
-1
No files found.
lib/gitlab/git/gitmodules_parser.rb
View file @
1c40f18f
...
@@ -46,6 +46,8 @@ module Gitlab
...
@@ -46,6 +46,8 @@ module Gitlab
iterator
=
State
.
new
iterator
=
State
.
new
@content
.
split
(
"
\n
"
).
each_with_object
(
iterator
)
do
|
text
,
iterator
|
@content
.
split
(
"
\n
"
).
each_with_object
(
iterator
)
do
|
text
,
iterator
|
text
.
chomp!
next
if
text
=~
/^\s*#/
next
if
text
=~
/^\s*#/
if
text
=~
/\A\[submodule "(?<name>[^"]+)"\]\z/
if
text
=~
/\A\[submodule "(?<name>[^"]+)"\]\z/
...
@@ -55,7 +57,7 @@ module Gitlab
...
@@ -55,7 +57,7 @@ module Gitlab
next
unless
text
=~
/\A\s*(?<key>\w+)\s*=\s*(?<value>.*)\z/
next
unless
text
=~
/\A\s*(?<key>\w+)\s*=\s*(?<value>.*)\z/
value
=
$~
[
:value
]
.
chomp
value
=
$~
[
:value
]
iterator
.
set_attribute
(
$~
[
:key
],
value
)
iterator
.
set_attribute
(
$~
[
:key
],
value
)
end
end
end
end
...
...
spec/lib/gitlab/git/gitmodules_parser_spec.rb
View file @
1c40f18f
...
@@ -2,7 +2,7 @@ require 'spec_helper'
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
Gitlab
::
Git
::
GitmodulesParser
do
describe
Gitlab
::
Git
::
GitmodulesParser
do
it
'should parse a .gitmodules file correctly'
do
it
'should parse a .gitmodules file correctly'
do
parser
=
described_class
.
new
(
<<-
'GITMODULES'
.
strip_heredoc
)
data
=
<<~
GITMODULES
[submodule "vendor/libgit2"]
[submodule "vendor/libgit2"]
path = vendor/libgit2
path = vendor/libgit2
[submodule "vendor/libgit2"]
[submodule "vendor/libgit2"]
...
@@ -16,6 +16,7 @@ describe Gitlab::Git::GitmodulesParser do
...
@@ -16,6 +16,7 @@ describe Gitlab::Git::GitmodulesParser do
url = https://example.com/another/project
url = https://example.com/another/project
GITMODULES
GITMODULES
parser
=
described_class
.
new
(
data
.
gsub
(
"
\n
"
,
"
\r\n
"
))
modules
=
parser
.
parse
modules
=
parser
.
parse
expect
(
modules
).
to
eq
({
expect
(
modules
).
to
eq
({
...
...
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