2017-04-17 20:13:08 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Gitlab::Git::GitmodulesParser do
|
|
|
|
it 'should parse a .gitmodules file correctly' do
|
2018-03-30 18:15:31 -04:00
|
|
|
data = <<~GITMODULES
|
2017-04-17 20:13:08 -04:00
|
|
|
[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-03-30 18:15:31 -04:00
|
|
|
parser = described_class.new(data.gsub("\n", "\r\n"))
|
2017-04-17 20:13:08 -04:00
|
|
|
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
|