Skip to content
Snippets Groups Projects
Commit ee7fba4b authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent e0ab7eda
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -7,9 +7,7 @@ module SubmoduleHelper
 
# links to files listing for submodule if submodule is a project on this server
def submodule_links(submodule_item, ref = nil, repository = @repository)
url = repository.submodule_url_for(ref, submodule_item.path)
submodule_links_for_url(submodule_item.id, url, repository)
repository.submodule_links.for(submodule_item, ref)
end
 
def submodule_links_for_url(submodule_item_id, url, repository)
Loading
Loading
Loading
Loading
@@ -1094,6 +1094,10 @@ class Repository
message: message)
end
 
def submodule_links
@submodule_links ||= ::Gitlab::SubmoduleLinks.new(self)
end
def update_submodule(user, submodule, commit_sha, message:, branch:)
with_cache_hooks do
raw.update_submodule(
Loading
Loading
---
title: Eliminate Gitaly N+1 queries loading submodules
merge_request: 23292
author:
type: performance
Loading
Loading
@@ -8,6 +8,11 @@ describe SubmoduleHelper do
let(:submodule_item) { double(id: 'hash', path: 'rack') }
let(:config) { Gitlab.config.gitlab }
let(:repo) { double }
let(:submodules) { Gitlab::SubmoduleLinks.new(repo) }
before do
allow(repo).to receive(:submodule_links).and_return(submodules)
end
 
shared_examples 'submodule_links' do
context 'submodule on self' do
Loading
Loading
@@ -163,7 +168,7 @@ describe SubmoduleHelper do
let(:repo) { double(:repo, project: project) }
 
def expect_relative_link_to_resolve_to(relative_path, expected_path)
allow(repo).to receive(:submodule_url_for).and_return(relative_path)
stub_url(relative_path)
result = subject
 
expect(result).to eq([expected_path, "#{expected_path}/tree/#{submodule_item.id}"])
Loading
Loading
@@ -183,7 +188,7 @@ describe SubmoduleHelper do
 
context 'repo path resolves to be located at root (namespace absent)' do
it 'returns nil' do
allow(repo).to receive(:submodule_url_for).and_return('../../test.git')
stub_url('../../test.git')
 
result = subject
 
Loading
Loading
@@ -193,7 +198,7 @@ describe SubmoduleHelper do
 
context 'repo path resolves to be located underneath current project path' do
it 'returns nil because it is not possible to have repo nested under another repo' do
allow(repo).to receive(:submodule_url_for).and_return('./test.git')
stub_url('./test.git')
 
result = subject
 
Loading
Loading
@@ -263,6 +268,7 @@ describe SubmoduleHelper do
end
 
def stub_url(url)
allow(submodules).to receive(:submodule_url_for).and_return(url)
allow(repo).to receive(:submodule_url_for).and_return(url)
end
end
Loading
Loading
@@ -2714,4 +2714,10 @@ describe Repository do
.to change { Gitlab::GitalyClient.get_request_count }.by(1)
end
end
describe '#submodule_links' do
it 'returns an instance of Gitlab::SubmoduleLinks' do
expect(repository.submodule_links).to be_a(Gitlab::SubmoduleLinks)
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment