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
0187018e
Commit
0187018e
authored
Sep 01, 2017
by
Jacob Vosmaer (GitLab)
Committed by
Douwe Maan
Sep 01, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify Git interactions in AfterImportService
parent
7d3e888d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
app/services/projects/after_import_service.rb
app/services/projects/after_import_service.rb
+2
-7
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+8
-2
No files found.
app/services/projects/after_import_service.rb
View file @
0187018e
module
Projects
module
Projects
class
AfterImportService
class
AfterImportService
RESERVED_REFS_REGEXP
=
RESERVED_REF_PREFIXES
=
Repository
::
RESERVED_REFS_NAMES
.
map
{
|
n
|
File
.
join
(
'refs'
,
n
,
'/'
)
}
%r{
\A
refs/(?:
#{
Regexp
.
union
(
*
Repository
::
RESERVED_REFS_NAMES
)
}
)/}
def
initialize
(
project
)
def
initialize
(
project
)
@project
=
project
@project
=
project
...
@@ -9,7 +8,7 @@ module Projects
...
@@ -9,7 +8,7 @@ module Projects
def
execute
def
execute
Projects
::
HousekeepingService
.
new
(
@project
).
execute
do
Projects
::
HousekeepingService
.
new
(
@project
).
execute
do
repository
.
delete_
refs
(
*
garbage_refs
)
repository
.
delete_
all_refs_except
(
RESERVED_REF_PREFIXES
)
end
end
rescue
Projects
::
HousekeepingService
::
LeaseTaken
=>
e
rescue
Projects
::
HousekeepingService
::
LeaseTaken
=>
e
Rails
.
logger
.
info
(
Rails
.
logger
.
info
(
...
@@ -18,10 +17,6 @@ module Projects
...
@@ -18,10 +17,6 @@ module Projects
private
private
def
garbage_refs
@garbage_refs
||=
repository
.
all_ref_names_except
(
RESERVED_REFS_REGEXP
)
end
def
repository
def
repository
@repository
||=
@project
.
repository
@repository
||=
@project
.
repository
end
end
...
...
lib/gitlab/git/repository.rb
View file @
0187018e
...
@@ -250,11 +250,17 @@ module Gitlab
...
@@ -250,11 +250,17 @@ module Gitlab
branch_names
+
tag_names
branch_names
+
tag_names
end
end
def
delete_all_refs_except
(
prefixes
)
delete_refs
(
*
all_ref_names_except
(
prefixes
))
end
# Returns an Array of all ref names, except when it's matching pattern
# Returns an Array of all ref names, except when it's matching pattern
#
#
# regexp - The pattern for ref names we don't want
# regexp - The pattern for ref names we don't want
def
all_ref_names_except
(
regexp
)
def
all_ref_names_except
(
prefixes
)
rugged
.
references
.
reject
{
|
ref
|
ref
.
name
=~
regexp
}.
map
(
&
:name
)
rugged
.
references
.
reject
do
|
ref
|
prefixes
.
any?
{
|
p
|
ref
.
name
.
start_with?
(
p
)
}
end
.
map
(
&
:name
)
end
end
# Discovers the default branch based on the repository's available branches
# Discovers the default branch based on the repository's available branches
...
...
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