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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
d7cdcc51
Commit
d7cdcc51
authored
Apr 27, 2016
by
Minqi Pan
Committed by
Rémy Coutable
Jan 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expire related caches after changing HEAD
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
f1bd9f05
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
16 deletions
+32
-16
app/models/project.rb
app/models/project.rb
+1
-1
app/models/repository.rb
app/models/repository.rb
+5
-0
changelogs/unreleased/pmq20-gitlab-ce-psvr-head-cache.yml
changelogs/unreleased/pmq20-gitlab-ce-psvr-head-cache.yml
+4
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+4
-7
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+18
-8
No files found.
app/models/project.rb
View file @
d7cdcc51
...
...
@@ -1032,7 +1032,7 @@ class Project < ActiveRecord::Base
"refs/heads/
#{
branch
}
"
,
force:
true
)
repository
.
copy_gitattributes
(
branch
)
repository
.
expire_avatar_cache
repository
.
after_change_head
reload_default_branch
end
...
...
app/models/repository.rb
View file @
d7cdcc51
...
...
@@ -439,6 +439,11 @@ class Repository
expire_content_cache
end
# Runs code after the HEAD of a repository is changed.
def
after_change_head
expire_method_caches
(
METHOD_CACHES_FOR_FILE_TYPES
.
keys
)
end
# Runs code after a repository has been forked/imported.
def
after_import
expire_content_cache
...
...
changelogs/unreleased/pmq20-gitlab-ce-psvr-head-cache.yml
0 → 100644
View file @
d7cdcc51
---
title
:
Expire related caches after changing HEAD
merge_request
:
author
:
Minqi Pan
spec/models/project_spec.rb
View file @
d7cdcc51
...
...
@@ -1545,11 +1545,13 @@ describe Project, models: true do
end
end
describe
'change_head'
do
describe
'
#
change_head'
do
let
(
:project
)
{
create
(
:project
)
}
it
'calls the before_change_head
method
'
do
it
'calls the before_change_head
and after_change_head methods
'
do
expect
(
project
.
repository
).
to
receive
(
:before_change_head
)
expect
(
project
.
repository
).
to
receive
(
:after_change_head
)
project
.
change_head
(
project
.
default_branch
)
end
...
...
@@ -1565,11 +1567,6 @@ describe Project, models: true do
project
.
change_head
(
project
.
default_branch
)
end
it
'expires the avatar cache'
do
expect
(
project
.
repository
).
to
receive
(
:expire_avatar_cache
)
project
.
change_head
(
project
.
default_branch
)
end
it
'reloads the default branch'
do
expect
(
project
).
to
receive
(
:reload_default_branch
)
project
.
change_head
(
project
.
default_branch
)
...
...
spec/models/repository_spec.rb
View file @
d7cdcc51
...
...
@@ -1150,6 +1150,24 @@ describe Repository, models: true do
end
end
describe
'#after_change_head'
do
it
'flushes the readme cache'
do
expect
(
repository
).
to
receive
(
:expire_method_caches
).
with
([
:readme
,
:changelog
,
:license
,
:contributing
,
:version
,
:gitignore
,
:koding
,
:gitlab_ci
,
:avatar
])
repository
.
after_change_head
end
end
describe
'#before_push_tag'
do
it
'flushes the cache'
do
expect
(
repository
).
to
receive
(
:expire_statistics_caches
)
...
...
@@ -1513,14 +1531,6 @@ describe Repository, models: true do
end
end
describe
'#expire_avatar_cache'
do
it
'expires the cache'
do
expect
(
repository
).
to
receive
(
:expire_method_caches
).
with
(
%i(avatar)
)
repository
.
expire_avatar_cache
end
end
describe
'#file_on_head'
do
context
'with a non-existing repository'
do
it
'returns nil'
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