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
Jérome Perrin
gitlab-ce
Commits
3922b803
Commit
3922b803
authored
Jul 18, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename the methods to make it fit with current name
parent
ffc5b29b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
20 deletions
+20
-20
app/models/commit.rb
app/models/commit.rb
+1
-1
lib/gitlab/cache/request_cache.rb
lib/gitlab/cache/request_cache.rb
+9
-9
lib/gitlab/user_access.rb
lib/gitlab/user_access.rb
+5
-5
spec/lib/gitlab/cache/request_cache_spec.rb
spec/lib/gitlab/cache/request_cache_spec.rb
+5
-5
No files found.
app/models/commit.rb
View file @
3922b803
...
...
@@ -172,7 +172,7 @@ class Commit
def
author
User
.
find_by_any_email
(
author_email
.
downcase
)
end
request_
store_wrap
(
:author
)
{
author_email
.
downcase
}
request_
cache
(
:author
)
{
author_email
.
downcase
}
def
committer
@committer
||=
User
.
find_by_any_email
(
committer_email
.
downcase
)
...
...
lib/gitlab/cache/request_cache.rb
View file @
3922b803
...
...
@@ -10,11 +10,11 @@ module Gitlab
# class UserAccess
# extend Gitlab::Cache::RequestCache
#
# request_
store_wrap
_key do
# request_
cache
_key do
# [user&.id, project&.id]
# end
#
# request_
store_wrap
def can_push_to_branch?(ref)
# request_
cache
def can_push_to_branch?(ref)
# # ...
# end
# end
...
...
@@ -31,7 +31,7 @@ module Gitlab
# def author
# User.find_by_any_email(author_email.downcase)
# end
# request_
store_wrap
(:author) { author_email.downcase }
# request_
cache
(:author) { author_email.downcase }
# end
#
# So that we could have different strategies for different methods
...
...
@@ -45,15 +45,15 @@ module Gitlab
klass
.
prepend
(
extension
)
end
def
request_
store_wrap
_key
(
&
block
)
def
request_
cache
_key
(
&
block
)
if
block_given?
@request_
store_wrap
_key
=
block
@request_
cache
_key
=
block
else
@request_
store_wrap
_key
@request_
cache
_key
end
end
def
request_
store_wrap
(
method_name
,
&
method_key_block
)
def
request_
cache
(
method_name
,
&
method_key_block
)
const_get
(
:RequestCacheExtension
).
module_eval
do
cache_key_method_name
=
"
#{
method_name
}
_cache_key"
...
...
@@ -77,8 +77,8 @@ module Gitlab
define_method
(
cache_key_method_name
)
do
|
args
|
klass
=
self
.
class
instance_key
=
instance_exec
(
&
klass
.
request_
store_wrap
_key
)
if
klass
.
request_
store_wrap
_key
instance_key
=
instance_exec
(
&
klass
.
request_
cache
_key
)
if
klass
.
request_
cache
_key
method_key
=
instance_exec
(
&
method_key_block
)
if
method_key_block
...
...
lib/gitlab/user_access.rb
View file @
3922b803
...
...
@@ -2,7 +2,7 @@ module Gitlab
class
UserAccess
extend
Gitlab
::
Cache
::
RequestCache
request_
store_wrap
_key
do
request_
cache
_key
do
[
user
&
.
id
,
project
&
.
id
]
end
...
...
@@ -34,7 +34,7 @@ module Gitlab
true
end
request_
store_wrap
def
can_create_tag?
(
ref
)
request_
cache
def
can_create_tag?
(
ref
)
return
false
unless
can_access_git?
if
ProtectedTag
.
protected?
(
project
,
ref
)
...
...
@@ -44,7 +44,7 @@ module Gitlab
end
end
request_
store_wrap
def
can_delete_branch?
(
ref
)
request_
cache
def
can_delete_branch?
(
ref
)
return
false
unless
can_access_git?
if
ProtectedBranch
.
protected?
(
project
,
ref
)
...
...
@@ -54,7 +54,7 @@ module Gitlab
end
end
request_
store_wrap
def
can_push_to_branch?
(
ref
)
request_
cache
def
can_push_to_branch?
(
ref
)
return
false
unless
can_access_git?
if
ProtectedBranch
.
protected?
(
project
,
ref
)
...
...
@@ -66,7 +66,7 @@ module Gitlab
end
end
request_
store_wrap
def
can_merge_to_branch?
(
ref
)
request_
cache
def
can_merge_to_branch?
(
ref
)
return
false
unless
can_access_git?
if
ProtectedBranch
.
protected?
(
project
,
ref
)
...
...
spec/lib/gitlab/cache/request_cache_spec.rb
View file @
3922b803
...
...
@@ -18,18 +18,18 @@ describe Gitlab::Cache::RequestCache, :request_store do
self
.
extra
=
nil
end
request_
store_wrap
def
compute
(
arg
)
request_
cache
def
compute
(
arg
)
result
<<
arg
end
request_
store_wrap
def
repute
(
arg
)
request_
cache
def
repute
(
arg
)
result
<<
arg
end
def
dispute
(
arg
)
result
<<
arg
end
request_
store_wrap
(
:dispute
)
{
extra
}
request_
cache
(
:dispute
)
{
extra
}
end
end
...
...
@@ -80,9 +80,9 @@ describe Gitlab::Cache::RequestCache, :request_store do
expect
(
algorithm
.
result
).
to
eq
(
result
)
end
context
'when request_
store_wrap
_key is provided'
do
context
'when request_
cache
_key is provided'
do
before
do
klass
.
request_
store_wrap
_key
do
klass
.
request_
cache
_key
do
[
id
,
name
]
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