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
00cd5d93
Commit
00cd5d93
authored
Nov 21, 2017
by
Jacob Vosmaer (GitLab)
Committed by
Rémy Coutable
Nov 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Redis cache for branch existence checks
parent
2822254e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
5 deletions
+26
-5
app/models/repository.rb
app/models/repository.rb
+1
-5
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+25
-0
No files found.
app/models/repository.rb
View file @
00cd5d93
...
...
@@ -217,11 +217,7 @@ class Repository
def
branch_exists?
(
branch_name
)
return
false
unless
raw_repository
@branch_exists_memo
||=
Hash
.
new
do
|
hash
,
key
|
hash
[
key
]
=
raw_repository
.
branch_exists?
(
key
)
end
@branch_exists_memo
[
branch_name
]
branch_names
.
include?
(
branch_name
)
end
def
ref_exists?
(
ref
)
...
...
spec/models/repository_spec.rb
View file @
00cd5d93
...
...
@@ -1166,6 +1166,31 @@ describe Repository do
end
end
describe
'#branch_exists?'
do
it
'uses branch_names'
do
allow
(
repository
).
to
receive
(
:branch_names
).
and_return
([
'foobar'
])
expect
(
repository
.
branch_exists?
(
'foobar'
)).
to
eq
(
true
)
expect
(
repository
.
branch_exists?
(
'master'
)).
to
eq
(
false
)
end
end
describe
'#branch_names'
,
:use_clean_rails_memory_store_caching
do
let
(
:fake_branch_names
)
{
[
'foobar'
]
}
it
'gets cached across Repository instances'
do
allow
(
repository
.
raw_repository
).
to
receive
(
:branch_names
).
once
.
and_return
(
fake_branch_names
)
expect
(
repository
.
branch_names
).
to
eq
(
fake_branch_names
)
fresh_repository
=
Project
.
find
(
project
.
id
).
repository
expect
(
fresh_repository
.
object_id
).
not_to
eq
(
repository
.
object_id
)
expect
(
fresh_repository
.
raw_repository
).
not_to
receive
(
:branch_names
)
expect
(
fresh_repository
.
branch_names
).
to
eq
(
fake_branch_names
)
end
end
describe
'#update_autocrlf_option'
do
describe
'when autocrlf is not already set to :input'
do
before
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