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
bea29327
Commit
bea29327
authored
Aug 24, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Just use methods over constants, so that we could
take the advantage that if they're not used, we could garbage collect those data, reducing memory footprint.
parent
140ac8d2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
cleanup_service.rb
app/services/projects/import_export/cleanup_service.rb
+14
-6
cleanup_service_spec.rb
spec/services/projects/import_export/cleanup_service_spec.rb
+1
-1
No files found.
app/services/projects/import_export/cleanup_service.rb
View file @
bea29327
module
Projects
module
ImportExport
class
CleanupService
RESERVED_REFS_NAMES
=
def
self
.
reserved_refs_names
%w[heads tags merge-requests keep-around environments]
RESERVED_REFS_REGEXP
=
%r{
\A
refs/(?:
#{
RESERVED_REFS_NAMES
.
map
(
&
Regexp
.
method
(
:escape
)).
join
(
'|'
)
}
)/}x
end
def
self
.
reserved_refs_regexp
names
=
reserved_refs_names
.
map
(
&
Regexp
.
method
(
:escape
)).
join
(
'|'
)
%r{
\A
refs/(?:
#{
names
}
)/}
end
attr_reader
:project
...
...
@@ -23,8 +27,12 @@ module Projects
private
def
garbage_refs
@garbage_refs
||=
rugged
.
references
.
reject
do
|
ref
|
ref
.
name
=~
RESERVED_REFS_REGEXP
@garbage_refs
||=
begin
reserved_refs_regexp
=
self
.
class
.
reserved_refs_regexp
rugged
.
references
.
reject
do
|
ref
|
ref
.
name
=~
reserved_refs_regexp
end
end
end
...
...
spec/services/projects/import_export/cleanup_service_spec.rb
View file @
bea29327
...
...
@@ -37,7 +37,7 @@ describe Projects::ImportExport::CleanupService do
end
end
described_class
::
RESERVED_REFS_NAMES
.
each
do
|
name
|
described_class
.
reserved_refs_names
.
each
do
|
name
|
context
"with a ref in refs/
#{
name
}
/tmp"
do
before
do
repository
.
write_ref
(
"refs/
#{
name
}
/tmp"
,
sha
)
...
...
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