Commit dbc1f5bf authored by Douwe Maan's avatar Douwe Maan Committed by Jose Ivan Vargas

Merge branch 'malformed-submodule' into 'master'

Handle missing .gitmodules when getting submodule urls

See merge request !13509
parent c03d9d5f
...@@ -826,6 +826,8 @@ module Gitlab ...@@ -826,6 +826,8 @@ module Gitlab
return unless commit_object && commit_object.type == :COMMIT return unless commit_object && commit_object.type == :COMMIT
gitmodules = gitaly_commit_client.tree_entry(ref, '.gitmodules', Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE) gitmodules = gitaly_commit_client.tree_entry(ref, '.gitmodules', Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE)
return unless gitmodules
found_module = GitmodulesParser.new(gitmodules.data).parse[path] found_module = GitmodulesParser.new(gitmodules.data).parse[path]
found_module && found_module['url'] found_module && found_module['url']
......
...@@ -307,8 +307,8 @@ describe Gitlab::Git::Commit, seed_helper: true do ...@@ -307,8 +307,8 @@ describe Gitlab::Git::Commit, seed_helper: true do
commits.map(&:id) commits.map(&:id)
end end
it 'has 33 elements' do it 'has 34 elements' do
expect(subject.size).to eq(33) expect(subject.size).to eq(34)
end end
it 'includes the expected commits' do it 'includes the expected commits' do
......
...@@ -289,7 +289,13 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -289,7 +289,13 @@ describe Gitlab::Git::Repository, seed_helper: true do
it { expect(submodule_url('six')).to eq('git://github.com/randx/six.git') } it { expect(submodule_url('six')).to eq('git://github.com/randx/six.git') }
end end
context 'no submodules at commit' do context 'no .gitmodules at commit' do
let(:ref) { '9596bc54a6f0c0c98248fe97077eb5ccf48a98d0' }
it { expect(submodule_url('six')).to eq(nil) }
end
context 'no gitlink entry' do
let(:ref) { '6d39438' } let(:ref) { '6d39438' }
it { expect(submodule_url('six')).to eq(nil) } it { expect(submodule_url('six')).to eq(nil) }
...@@ -981,7 +987,7 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -981,7 +987,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
describe '#branch_count' do describe '#branch_count' do
it 'returns the number of branches' do it 'returns the number of branches' do
expect(repository.branch_count).to eq(9) expect(repository.branch_count).to eq(10)
end end
end end
......
xOn1 䜯 9&O "noYD6ՒҪ?j;wQ GrN(HPrArR7tpM#M”cNrsI
%p>۫pz?Y3XBB̰GB4 p?kv۞y~W])[a<CP_
\ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
46e1395e609395de004cacd4b142865ab0e52a29 refs/heads/gitattributes-updated 46e1395e609395de004cacd4b142865ab0e52a29 refs/heads/gitattributes-updated
4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6 refs/heads/master 4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6 refs/heads/master
5937ac0a7beb003549fc5fd26fc247adbce4a52e refs/heads/merge-test 5937ac0a7beb003549fc5fd26fc247adbce4a52e refs/heads/merge-test
9596bc54a6f0c0c98248fe97077eb5ccf48a98d0 refs/heads/missing-gitmodules
f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8 refs/tags/v1.0.0 f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8 refs/tags/v1.0.0
^6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9 ^6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b refs/tags/v1.1.0 8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b refs/tags/v1.1.0
......
...@@ -97,6 +97,7 @@ module SeedRepo ...@@ -97,6 +97,7 @@ module SeedRepo
gitattributes-updated gitattributes-updated
master master
merge-test merge-test
missing-gitmodules
].freeze ].freeze
TAGS = %w[ TAGS = %w[
v1.0.0 v1.0.0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment