2020-01-01 13:55:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
require 'fast_spec_helper'
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Gitlab::Git::GitmodulesParser do
|
2019-07-07 11:18:12 +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
|