BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
d9885160
Commit
d9885160
authored
Jun 30, 2016
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '18709-branch-tag-collection-caching' into 'master'
Project dashboard appears to be loading tags on every request See merge request !4996
parents
8a245b80
5fe85bc8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
14 deletions
+78
-14
CHANGELOG
CHANGELOG
+1
-0
repository.rb
app/models/repository.rb
+8
-8
repository_spec.rb
spec/models/repository_spec.rb
+8
-6
git_push_service_spec.rb
spec/services/git_push_service_spec.rb
+36
-0
git_tag_push_service_spec.rb
spec/services/git_tag_push_service_spec.rb
+25
-0
No files found.
CHANGELOG
View file @
d9885160
...
...
@@ -22,6 +22,7 @@ v 8.10.0 (unreleased)
- PipelinesFinder uses git cache data
- Check for conflicts with existing Project's wiki path when creating a new project.
- Remove unused front-end variable -> default_issues_tracker
- Better caching of git calls on ProjectsController#show.
- Add API endpoint for a group issues !4520 (mahcsig)
- Add Bugzilla integration !4930 (iamtjg)
- Allow [ci skip] to be in any case and allow [skip ci]. !4785 (simon_w)
...
...
app/models/repository.rb
View file @
d9885160
...
...
@@ -246,24 +246,26 @@ class Repository
end
end
# Keys for data that can be affected for any commit push.
def
cache_keys
%i(size
branch_names tag_names branch_count tag_count
commit_count
%i(size commit_count
readme version contribution_guide changelog
license_blob license_key gitignore)
end
# Keys for data on branch/tag operations.
def
cache_keys_for_branches_and_tags
%i(branch_names tag_names branch_count tag_count)
end
def
build_cache
cache_keys
.
each
do
|
key
|
(
cache_keys
+
cache_keys_for_branches_and_tags
)
.
each
do
|
key
|
unless
cache
.
exist?
(
key
)
send
(
key
)
end
end
end
def
expire_gitignore
cache
.
expire
(
:gitignore
)
end
def
expire_tags_cache
cache
.
expire
(
:tag_names
)
@tags
=
nil
...
...
@@ -286,8 +288,6 @@ class Repository
# This ensures this particular cache is flushed after the first commit to a
# new repository.
expire_emptiness_caches
if
empty?
expire_branch_count_cache
expire_tag_count_cache
end
def
expire_branch_cache
(
branch_name
=
nil
)
...
...
spec/models/repository_spec.rb
View file @
d9885160
...
...
@@ -531,8 +531,6 @@ describe Repository, models: true do
describe
'#expire_cache'
do
it
'expires all caches'
do
expect
(
repository
).
to
receive
(
:expire_branch_cache
)
expect
(
repository
).
to
receive
(
:expire_branch_count_cache
)
expect
(
repository
).
to
receive
(
:expire_tag_count_cache
)
repository
.
expire_cache
end
...
...
@@ -1055,12 +1053,14 @@ describe Repository, models: true do
let
(
:cache
)
{
repository
.
send
(
:cache
)
}
it
'builds the caches if they do not already exist'
do
cache_keys
=
repository
.
cache_keys
+
repository
.
cache_keys_for_branches_and_tags
expect
(
cache
).
to
receive
(
:exist?
).
exactly
(
repository
.
cache_keys
.
length
).
exactly
(
cache_keys
.
length
).
times
.
and_return
(
false
)
repository
.
cache_keys
.
each
do
|
key
|
cache_keys
.
each
do
|
key
|
expect
(
repository
).
to
receive
(
key
)
end
...
...
@@ -1068,12 +1068,14 @@ describe Repository, models: true do
end
it
'does not build any caches that already exist'
do
cache_keys
=
repository
.
cache_keys
+
repository
.
cache_keys_for_branches_and_tags
expect
(
cache
).
to
receive
(
:exist?
).
exactly
(
repository
.
cache_keys
.
length
).
exactly
(
cache_keys
.
length
).
times
.
and_return
(
true
)
repository
.
cache_keys
.
each
do
|
key
|
cache_keys
.
each
do
|
key
|
expect
(
repository
).
not_to
receive
(
key
)
end
...
...
spec/services/git_push_service_spec.rb
View file @
d9885160
...
...
@@ -40,6 +40,18 @@ describe GitPushService, services: true do
subject
end
it
'flushes the branches cache'
do
expect
(
project
.
repository
).
to
receive
(
:expire_branches_cache
)
subject
end
it
'flushes the branch count cache'
do
expect
(
project
.
repository
).
to
receive
(
:expire_branch_count_cache
)
subject
end
end
context
'existing branch'
do
...
...
@@ -52,6 +64,18 @@ describe GitPushService, services: true do
subject
end
it
'does not flush the branches cache'
do
expect
(
project
.
repository
).
not_to
receive
(
:expire_branches_cache
)
subject
end
it
'does not flush the branch count cache'
do
expect
(
project
.
repository
).
not_to
receive
(
:expire_branch_count_cache
)
subject
end
end
context
'rm branch'
do
...
...
@@ -66,6 +90,18 @@ describe GitPushService, services: true do
subject
end
it
'flushes the branches cache'
do
expect
(
project
.
repository
).
to
receive
(
:expire_branches_cache
)
subject
end
it
'flushes the branch count cache'
do
expect
(
project
.
repository
).
to
receive
(
:expire_branch_count_cache
)
subject
end
it
'flushes general cached data'
do
expect
(
project
.
repository
).
to
receive
(
:expire_cache
).
with
(
'master'
,
newrev
)
...
...
spec/services/git_tag_push_service_spec.rb
View file @
d9885160
...
...
@@ -11,6 +11,31 @@ describe GitTagPushService, services: true do
let
(
:newrev
)
{
"8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b"
}
# gitlab-test: git rev-parse refs/tags/v1.1.0
let
(
:ref
)
{
'refs/tags/v1.1.0'
}
describe
"Push tags"
do
subject
do
service
.
execute
service
end
it
'flushes general cached data'
do
expect
(
project
.
repository
).
to
receive
(
:expire_cache
)
subject
end
it
'flushes the tags cache'
do
expect
(
project
.
repository
).
to
receive
(
:expire_tags_cache
)
subject
end
it
'flushes the tag count cache'
do
expect
(
project
.
repository
).
to
receive
(
:expire_tag_count_cache
)
subject
end
end
describe
"Git Tag Push Data"
do
before
do
service
.
execute
...
...
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