Commit cf131bf7 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Make Gitlab::Ggit::Repository#submodules private

parent 99bdfd18
...@@ -605,22 +605,6 @@ class Repository ...@@ -605,22 +605,6 @@ class Repository
end end
end end
# Returns url for submodule
#
# Ex.
# @repository.submodule_url_for('master', 'rack')
# # => git@localhost:rack.git
#
def submodule_url_for(ref, path)
if submodules(ref).any?
submodule = submodules(ref)[path]
if submodule
submodule['url']
end
end
end
def last_commit_for_path(sha, path) def last_commit_for_path(sha, path)
sha = last_commit_id_for_path(sha, path) sha = last_commit_id_for_path(sha, path)
commit(sha) commit(sha)
......
...@@ -613,32 +613,20 @@ module Gitlab ...@@ -613,32 +613,20 @@ module Gitlab
rugged.rev_parse(oid_or_ref_name) rugged.rev_parse(oid_or_ref_name)
end end
# Return hash with submodules info for this repository # Returns url for submodule
# #
# Ex. # Ex.
# { # @repository.submodule_url_for('master', 'rack')
# "current_path/rack" => { # # => git@localhost:rack.git
# "name" => "original_path/rack",
# "id" => "c67be4624545b4263184c4a0e8f887efd0a66320",
# "url" => "git://github.com/chneukirchen/rack.git"
# },
# "encoding" => {
# "id" => ....
# }
# }
# #
def submodules(ref) def submodule_url_for(ref, path)
commit = rev_parse_target(ref) if submodules(ref).any?
return {} unless commit submodule = submodules(ref)[path]
begin if submodule
content = blob_content(commit, ".gitmodules") submodule['url']
rescue InvalidBlobName end
return {}
end end
parser = GitmodulesParser.new(content)
fill_submodule_ids(commit, parser.parse)
end end
# Return total commits count accessible from passed ref # Return total commits count accessible from passed ref
...@@ -976,6 +964,23 @@ module Gitlab ...@@ -976,6 +964,23 @@ module Gitlab
private private
# We are trying to deprecate this method because it does a lot of work
# but it seems to be used only to look up submodule URL's.
# https://gitlab.com/gitlab-org/gitaly/issues/329
def submodules(ref)
commit = rev_parse_target(ref)
return {} unless commit
begin
content = blob_content(commit, ".gitmodules")
rescue InvalidBlobName
return {}
end
parser = GitmodulesParser.new(content)
fill_submodule_ids(commit, parser.parse)
end
def alternate_object_directories def alternate_object_directories
Gitlab::Git::Env.all.values_at(*ALLOWED_OBJECT_DIRECTORIES_VARIABLES).compact Gitlab::Git::Env.all.values_at(*ALLOWED_OBJECT_DIRECTORIES_VARIABLES).compact
end end
......
...@@ -348,7 +348,7 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -348,7 +348,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) }
context 'where repo has submodules' do context 'where repo has submodules' do
let(:submodules) { repository.submodules('master') } let(:submodules) { repository.send(:submodules, 'master') }
let(:submodule) { submodules.first } let(:submodule) { submodules.first }
it { expect(submodules).to be_kind_of Hash } it { expect(submodules).to be_kind_of Hash }
...@@ -383,12 +383,12 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -383,12 +383,12 @@ describe Gitlab::Git::Repository, seed_helper: true do
end end
it 'should not have an entry for an uncommited submodule dir' do it 'should not have an entry for an uncommited submodule dir' do
submodules = repository.submodules('fix-existing-submodule-dir') submodules = repository.send(:submodules, 'fix-existing-submodule-dir')
expect(submodules).not_to have_key('submodule-existing-dir') expect(submodules).not_to have_key('submodule-existing-dir')
end end
it 'should handle tags correctly' do it 'should handle tags correctly' do
submodules = repository.submodules('v1.2.1') submodules = repository.send(:submodules, 'v1.2.1')
expect(submodules.first).to eq([ expect(submodules.first).to eq([
"six", { "six", {
...@@ -414,7 +414,7 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -414,7 +414,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
end end
context 'where repo doesn\'t have submodules' do context 'where repo doesn\'t have submodules' do
let(:submodules) { repository.submodules('6d39438') } let(:submodules) { repository.send(:submodules, '6d39438') }
it 'should return an empty hash' do it 'should return an empty hash' do
expect(submodules).to be_empty expect(submodules).to be_empty
end end
......
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