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
f8c3a58a
Commit
f8c3a58a
authored
Dec 08, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid Gitaly N+1 calls by caching tag_names
parent
0ea70802
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
0 deletions
+17
-0
app/models/repository.rb
app/models/repository.rb
+6
-0
spec/controllers/projects/pipeline_schedules_controller_spec.rb
...ontrollers/projects/pipeline_schedules_controller_spec.rb
+2
-0
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+9
-0
No files found.
app/models/repository.rb
View file @
f8c3a58a
...
@@ -221,6 +221,12 @@ class Repository
...
@@ -221,6 +221,12 @@ class Repository
branch_names
.
include?
(
branch_name
)
branch_names
.
include?
(
branch_name
)
end
end
def
tag_exists?
(
tag_name
)
return
false
unless
raw_repository
tag_names
.
include?
(
tag_name
)
end
def
ref_exists?
(
ref
)
def
ref_exists?
(
ref
)
!!
raw_repository
&
.
ref_exists?
(
ref
)
!!
raw_repository
&
.
ref_exists?
(
ref
)
rescue
ArgumentError
rescue
ArgumentError
...
...
spec/controllers/projects/pipeline_schedules_controller_spec.rb
View file @
f8c3a58a
...
@@ -7,6 +7,8 @@ describe Projects::PipelineSchedulesController do
...
@@ -7,6 +7,8 @@ describe Projects::PipelineSchedulesController do
set
(
:pipeline_schedule
)
{
create
(
:ci_pipeline_schedule
,
project:
project
)
}
set
(
:pipeline_schedule
)
{
create
(
:ci_pipeline_schedule
,
project:
project
)
}
describe
'GET #index'
do
describe
'GET #index'
do
render_views
let
(
:scope
)
{
nil
}
let
(
:scope
)
{
nil
}
let!
(
:inactive_pipeline_schedule
)
do
let!
(
:inactive_pipeline_schedule
)
do
create
(
:ci_pipeline_schedule
,
:inactive
,
project:
project
)
create
(
:ci_pipeline_schedule
,
:inactive
,
project:
project
)
...
...
spec/models/repository_spec.rb
View file @
f8c3a58a
...
@@ -1157,6 +1157,15 @@ describe Repository do
...
@@ -1157,6 +1157,15 @@ describe Repository do
end
end
end
end
describe
'#tag_exists?'
do
it
'uses tag_names'
do
allow
(
repository
).
to
receive
(
:tag_names
).
and_return
([
'foobar'
])
expect
(
repository
.
tag_exists?
(
'foobar'
)).
to
eq
(
true
)
expect
(
repository
.
tag_exists?
(
'master'
)).
to
eq
(
false
)
end
end
describe
'#branch_names'
,
:use_clean_rails_memory_store_caching
do
describe
'#branch_names'
,
:use_clean_rails_memory_store_caching
do
let
(
:fake_branch_names
)
{
[
'foobar'
]
}
let
(
:fake_branch_names
)
{
[
'foobar'
]
}
...
...
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