2017-09-10 17:25:29 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Gitlab::Git::GitmodulesParser do
|
2019-05-18 00:54:41 +05:30
|
|
|
it 'parses a .gitmodules file correctly' do
|
2018-05-09 12:01:36 +05:30
|
|
|
data = <<~GITMODULES
|
2017-09-10 17:25:29 +05:30
|
|
|
[submodule "vendor/libgit2"]
|
|
|
|
path = vendor/libgit2
|
|
|
|
[submodule "vendor/libgit2"]
|
|
|
|
url = https://github.com/nodegit/libgit2.git
|
|
|
|
|
|
|
|
# a comment
|
|
|
|
[submodule "moved"]
|
|
|
|
path = new/path
|
|
|
|
url = https://example.com/some/project
|
|
|
|
[submodule "bogus"]
|
|
|
|
url = https://example.com/another/project
|
|
|
|
GITMODULES
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
parser = described_class.new(data.gsub("\n", "\r\n"))
|
2017-09-10 17:25:29 +05:30
|
|
|
modules = parser.parse
|
|
|
|
|
|
|
|
expect(modules).to eq({
|
|
|
|
'vendor/libgit2' => { 'name' => 'vendor/libgit2',
|
|
|
|
'url' => 'https://github.com/nodegit/libgit2.git' },
|
|
|
|
'new/path' => { 'name' => 'moved',
|
|
|
|
'url' => 'https://example.com/some/project' }
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|