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
376d06dd
Commit
376d06dd
authored
Dec 09, 2020
by
Igor Drozdov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't call FindCommit for projects#show
It's not used by the view, so we can remove it
parent
2695d26e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
6 deletions
+33
-6
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+2
-1
changelogs/unreleased/id-remove-gitaly-request-from-project-show.yml
...unreleased/id-remove-gitaly-request-from-project-show.yml
+5
-0
lib/extracts_ref.rb
lib/extracts_ref.rb
+8
-2
spec/controllers/projects_controller_spec.rb
spec/controllers/projects_controller_spec.rb
+18
-3
No files found.
app/controllers/projects_controller.rb
View file @
376d06dd
...
...
@@ -19,7 +19,6 @@ class ProjectsController < Projects::ApplicationController
before_action
:redirect_git_extension
,
only:
[
:show
]
before_action
:project
,
except:
[
:index
,
:new
,
:create
,
:resolve
]
before_action
:repository
,
except:
[
:index
,
:new
,
:create
,
:resolve
]
before_action
:assign_ref_vars
,
if:
->
{
action_name
==
'show'
&&
repo_exists?
}
before_action
:project_export_enabled
,
only:
[
:export
,
:download_export
,
:remove_export
,
:generate_new_export
]
before_action
:present_project
,
only:
[
:edit
]
before_action
:authorize_download_code!
,
only:
[
:refs
]
...
...
@@ -138,6 +137,8 @@ class ProjectsController < Projects::ApplicationController
end
def
show
@id
,
@ref
,
@path
=
extract_ref_path
if
@project
.
import_in_progress?
redirect_to
project_import_path
(
@project
,
custom_import_params
)
return
...
...
changelogs/unreleased/id-remove-gitaly-request-from-project-show.yml
0 → 100644
View file @
376d06dd
---
title
:
Remove unnecessary Gitaly calls from projects#show
merge_request
:
49565
author
:
type
:
performance
lib/extracts_ref.rb
View file @
376d06dd
...
...
@@ -62,8 +62,7 @@ module ExtractsRef
#
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def
assign_ref_vars
@id
=
get_id
@ref
,
@path
=
extract_ref
(
@id
)
@id
,
@ref
,
@path
=
extract_ref_path
@repo
=
repository_container
.
repository
raise
InvalidPathError
if
@ref
.
match?
(
/\s/
)
...
...
@@ -76,6 +75,13 @@ module ExtractsRef
@tree
||=
@repo
.
tree
(
@commit
.
id
,
@path
)
# rubocop:disable Gitlab/ModuleWithInstanceVariables
end
def
extract_ref_path
id
=
get_id
ref
,
path
=
extract_ref
(
id
)
[
id
,
ref
,
path
]
end
private
def
extract_raw_ref
(
id
)
...
...
spec/controllers/projects_controller_spec.rb
View file @
376d06dd
...
...
@@ -277,11 +277,16 @@ RSpec.describe ProjectsController do
render_views
def
get_show
get
:show
,
params:
{
namespace_id:
public_project
.
namespace
,
id:
public_project
}
end
it
"renders the activity view"
do
allow
(
controller
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
user
).
to
receive
(
:project_view
).
and_return
(
'activity'
)
get
:show
,
params:
{
namespace_id:
public_project
.
namespace
,
id:
public_project
}
get_show
expect
(
response
).
to
render_template
(
'_activity'
)
end
...
...
@@ -289,7 +294,8 @@ RSpec.describe ProjectsController do
allow
(
controller
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
user
).
to
receive
(
:project_view
).
and_return
(
'files'
)
get
:show
,
params:
{
namespace_id:
public_project
.
namespace
,
id:
public_project
}
get_show
expect
(
response
).
to
render_template
(
'_files'
)
end
...
...
@@ -297,9 +303,18 @@ RSpec.describe ProjectsController do
allow
(
controller
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
user
).
to
receive
(
:project_view
).
and_return
(
'readme'
)
get
:show
,
params:
{
namespace_id:
public_project
.
namespace
,
id:
public_project
}
get_show
expect
(
response
).
to
render_template
(
'_readme'
)
end
it
'does not make Gitaly requests'
,
:request_store
,
:clean_gitlab_redis_cache
do
# Warm up to populate repository cache
get_show
RequestStore
.
clear!
expect
{
get_show
}.
not_to
change
{
Gitlab
::
GitalyClient
.
get_request_count
}
end
end
context
"when the url contains .atom"
do
...
...
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