diff options
author | Rémy Coutable <remy@rymai.me> | 2017-06-19 17:51:55 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-06-19 17:51:55 +0000 |
commit | 2a39280db037867dce6345dee20366a87c66a691 (patch) | |
tree | 754b92b535d57ceb27cd407b5c8179f5747f3579 /spec | |
parent | 8a3f886b5be0ee678b09e01b2db03b7279ee6cab (diff) | |
parent | b30c16aa3298221b1957fef61e69c47be74bb25e (diff) | |
download | gitlab-ce-2a39280db037867dce6345dee20366a87c66a691.tar.gz |
Merge branch 'moved-submodules' into 'master'
repository: index submodules by path
See merge request !10798
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/git/gitmodules_parser_spec.rb | 28 | ||||
-rw-r--r-- | spec/lib/gitlab/git/repository_spec.rb | 8 |
2 files changed, 32 insertions, 4 deletions
diff --git a/spec/lib/gitlab/git/gitmodules_parser_spec.rb b/spec/lib/gitlab/git/gitmodules_parser_spec.rb new file mode 100644 index 00000000000..143aa2218c9 --- /dev/null +++ b/spec/lib/gitlab/git/gitmodules_parser_spec.rb @@ -0,0 +1,28 @@ +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 diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index eee4c9eab6d..02b3f167250 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -358,7 +358,7 @@ describe Gitlab::Git::Repository, seed_helper: true do expect(submodule).to eq([ "six", { "id" => "409f37c4f05865e4fb208c771485f211a22c4c2d", - "path" => "six", + "name" => "six", "url" => "git://github.com/randx/six.git" } ]) @@ -366,14 +366,14 @@ describe Gitlab::Git::Repository, seed_helper: true do it 'should handle nested submodules correctly' do nested = submodules['nested/six'] - expect(nested['path']).to eq('nested/six') + expect(nested['name']).to eq('nested/six') expect(nested['url']).to eq('git://github.com/randx/six.git') expect(nested['id']).to eq('24fb71c79fcabc63dfd8832b12ee3bf2bf06b196') end it 'should handle deeply nested submodules correctly' do nested = submodules['deeper/nested/six'] - expect(nested['path']).to eq('deeper/nested/six') + expect(nested['name']).to eq('deeper/nested/six') expect(nested['url']).to eq('git://github.com/randx/six.git') expect(nested['id']).to eq('24fb71c79fcabc63dfd8832b12ee3bf2bf06b196') end @@ -393,7 +393,7 @@ describe Gitlab::Git::Repository, seed_helper: true do expect(submodules.first).to eq([ "six", { "id" => "409f37c4f05865e4fb208c771485f211a22c4c2d", - "path" => "six", + "name" => "six", "url" => "git://github.com/randx/six.git" } ]) |