Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ee7fba4b
Commit
ee7fba4b
authored
Jan 20, 2020
by
GitLab Bot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add latest changes from gitlab-org/gitlab@master
parent
e0ab7eda
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
6 deletions
+25
-6
app/helpers/submodule_helper.rb
app/helpers/submodule_helper.rb
+1
-3
app/models/repository.rb
app/models/repository.rb
+4
-0
changelogs/unreleased/sh-reduce-gitaly-calls-submodules.yml
changelogs/unreleased/sh-reduce-gitaly-calls-submodules.yml
+5
-0
spec/helpers/submodule_helper_spec.rb
spec/helpers/submodule_helper_spec.rb
+9
-3
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+6
-0
No files found.
app/helpers/submodule_helper.rb
View file @
ee7fba4b
...
...
@@ -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
)
...
...
app/models/repository.rb
View file @
ee7fba4b
...
...
@@ -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
(
...
...
changelogs/unreleased/sh-reduce-gitaly-calls-submodules.yml
0 → 100644
View file @
ee7fba4b
---
title
:
Eliminate Gitaly N+1 queries loading submodules
merge_request
:
23292
author
:
type
:
performance
spec/helpers/submodule_helper_spec.rb
View file @
ee7fba4b
...
...
@@ -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
...
...
@@ -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
}
"
])
...
...
@@ -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
...
...
@@ -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
...
...
@@ -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
spec/models/repository_spec.rb
View file @
ee7fba4b
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment