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
30acfab5
Commit
30acfab5
authored
Apr 17, 2018
by
Grzegorz Bizon
Committed by
Filipa Lacerda
Apr 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge branch 'sh-memoize-repository-empty' into 'master'
Memoize Git::Repository#has_visible_content? See merge request gitlab-org/gitlab-ce!18383
parent
372b6584
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
6 deletions
+40
-6
repository.rb
app/models/repository.rb
+1
-0
sh-memoize-repository-empty.yml
changelogs/unreleased/sh-memoize-repository-empty.yml
+5
-0
repository.rb
lib/gitlab/git/repository.rb
+17
-6
repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+11
-0
repository_spec.rb
spec/models/repository_spec.rb
+6
-0
No files found.
app/models/repository.rb
View file @
30acfab5
...
...
@@ -331,6 +331,7 @@ class Repository
return
unless
empty?
expire_method_caches
(
%i(has_visible_content?)
)
raw_repository
.
expire_has_local_branches_cache
end
def
lookup_cache
...
...
changelogs/unreleased/sh-memoize-repository-empty.yml
0 → 100644
View file @
30acfab5
---
title
:
Memoize Git::Repository#has_visible_content?
merge_request
:
author
:
type
:
performance
lib/gitlab/git/repository.rb
View file @
30acfab5
...
...
@@ -9,6 +9,7 @@ module Gitlab
include
Gitlab
::
Git
::
RepositoryMirroring
include
Gitlab
::
Git
::
Popen
include
Gitlab
::
EncodingHelper
include
Gitlab
::
Utils
::
StrongMemoize
ALLOWED_OBJECT_DIRECTORIES_VARIABLES
=
%w[
GIT_OBJECT_DIRECTORY
...
...
@@ -230,13 +231,13 @@ module Gitlab
end
end
def
expire_has_local_branches_cache
clear_memoization
(
:has_local_branches
)
end
def
has_local_branches?
gitaly_migrate
(
:has_local_branches
,
status:
Gitlab
::
GitalyClient
::
MigrationStatus
::
OPT_OUT
)
do
|
is_enabled
|
if
is_enabled
gitaly_repository_client
.
has_local_branches?
else
has_local_branches_rugged?
end
strong_memoize
(
:has_local_branches
)
do
uncached_has_local_branches?
end
end
...
...
@@ -1516,6 +1517,16 @@ module Gitlab
private
def
uncached_has_local_branches?
gitaly_migrate
(
:has_local_branches
,
status:
Gitlab
::
GitalyClient
::
MigrationStatus
::
OPT_OUT
)
do
|
is_enabled
|
if
is_enabled
gitaly_repository_client
.
has_local_branches?
else
has_local_branches_rugged?
end
end
end
def
local_write_ref
(
ref_path
,
ref
,
old_ref:
nil
,
shell:
true
)
if
shell
shell_write_ref
(
ref_path
,
ref
,
old_ref
)
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
30acfab5
...
...
@@ -470,9 +470,20 @@ describe Gitlab::Git::Repository, seed_helper: true do
FileUtils
.
rm_rf
(
heads_dir
)
FileUtils
.
mkdir_p
(
heads_dir
)
repository
.
expire_has_local_branches_cache
expect
(
repository
.
has_local_branches?
).
to
eq
(
false
)
end
end
context
'memoizes the value'
do
it
'returns true'
do
expect
(
repository
).
to
receive
(
:uncached_has_local_branches?
).
once
.
and_call_original
2
.
times
do
expect
(
repository
.
has_local_branches?
).
to
eq
(
true
)
end
end
end
end
context
'with gitaly'
do
...
...
spec/models/repository_spec.rb
View file @
30acfab5
...
...
@@ -1437,6 +1437,12 @@ describe Repository do
repository
.
expire_emptiness_caches
end
it
'expires the memoized repository cache'
do
allow
(
repository
.
raw_repository
).
to
receive
(
:expire_has_local_branches_cache
).
and_call_original
repository
.
expire_emptiness_caches
end
end
describe
'skip_merges option'
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