b30c16aa32
Submodules have a name in the configuration, but this name is simply the path at which the submodule was initially checked in (by default -- the name is totally arbitrary). If a submodule is moved, it retains its original name, but its path changes. Since we discover submodules inside trees, we have their path but not necessarily their name. Make the submodules() function return the submodule hash indexed by path rather than name, so that renamed submodules can be looked up. Signed-off-by: David Turner <novalis@novalis.org>
28 lines
979 B
Ruby
28 lines
979 B
Ruby
require 'spec_helper'
|
|
|
|
describe Gitlab::Git::GitmodulesParser do
|
|
it 'should parse a .gitmodules file correctly' do
|
|
parser = described_class.new(<<-'GITMODULES'.strip_heredoc)
|
|
[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
|
|
|
|
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
|