Commit cf131bf7 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Make Gitlab::Ggit::Repository#submodules private

parent 99bdfd18
......@@ -605,22 +605,6 @@ class Repository
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)
sha = last_commit_id_for_path(sha, path)
commit(sha)
......
......@@ -613,32 +613,20 @@ module Gitlab
rugged.rev_parse(oid_or_ref_name)
end
# Return hash with submodules info for this repository
# Returns url for submodule
#
# Ex.
# {
# "current_path/rack" => {
# "name" => "original_path/rack",
# "id" => "c67be4624545b4263184c4a0e8f887efd0a66320",
# "url" => "git://github.com/chneukirchen/rack.git"
# },
# "encoding" => {
# "id" => ....
# }
# }
# @repository.submodule_url_for('master', 'rack')
# # => git@localhost:rack.git
#
def submodules(ref)
commit = rev_parse_target(ref)
return {} unless commit
def submodule_url_for(ref, path)
if submodules(ref).any?
submodule = submodules(ref)[path]
begin
content = blob_content(commit, ".gitmodules")
rescue InvalidBlobName
return {}
if submodule
submodule['url']
end
end
parser = GitmodulesParser.new(content)
fill_submodule_ids(commit, parser.parse)
end
# Return total commits count accessible from passed ref
......@@ -976,6 +964,23 @@ module Gitlab
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
Gitlab::Git::Env.all.values_at(*ALLOWED_OBJECT_DIRECTORIES_VARIABLES).compact
end
......
......@@ -348,7 +348,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) }
context 'where repo has submodules' do
let(:submodules) { repository.submodules('master') }
let(:submodules) { repository.send(:submodules, 'master') }
let(:submodule) { submodules.first }
it { expect(submodules).to be_kind_of Hash }
......@@ -383,12 +383,12 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
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')
end
it 'should handle tags correctly' do
submodules = repository.submodules('v1.2.1')
submodules = repository.send(:submodules, 'v1.2.1')
expect(submodules.first).to eq([
"six", {
......@@ -414,7 +414,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
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
expect(submodules).to be_empty
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