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
Léo-Paul Géneau
gitlab-ce
Commits
f2d4b24a
Commit
f2d4b24a
authored
Jan 03, 2018
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor code to use new import type
parent
11d0083e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
7 deletions
+9
-7
app/models/project.rb
app/models/project.rb
+4
-0
app/services/projects/create_service.rb
app/services/projects/create_service.rb
+3
-4
lib/gitlab/bare_repository_import/importer.rb
lib/gitlab/bare_repository_import/importer.rb
+1
-2
spec/lib/gitlab/bare_repository_import/importer_spec.rb
spec/lib/gitlab/bare_repository_import/importer_spec.rb
+1
-1
No files found.
app/models/project.rb
View file @
f2d4b24a
...
...
@@ -679,6 +679,10 @@ class Project < ActiveRecord::Base
Gitlab
::
UrlSanitizer
.
new
(
import_url
).
masked_url
end
def
bare_repository_import?
import_type
==
'bare_repository'
end
def
gitlab_project_import?
import_type
==
'gitlab_project'
end
...
...
app/services/projects/create_service.rb
View file @
f2d4b24a
...
...
@@ -12,7 +12,6 @@ module Projects
forked_from_project_id
=
params
.
delete
(
:forked_from_project_id
)
import_data
=
params
.
delete
(
:import_data
)
@skip_wiki
=
params
.
delete
(
:skip_wiki
)
@skip_import
=
params
.
delete
(
:skip_import
)
@project
=
Project
.
new
(
params
)
...
...
@@ -88,7 +87,7 @@ module Projects
def
after_create_actions
log_info
(
"
#{
@project
.
owner
.
name
}
created a new project
\"
#{
@project
.
name_with_namespace
}
\"
"
)
if
!
@project
.
gitlab_project_import?
||
@skip_import
unless
@project
.
gitlab_project_import?
@project
.
create_wiki
unless
skip_wiki?
create_services_from_active_templates
(
@project
)
...
...
@@ -121,7 +120,7 @@ module Projects
Project
.
transaction
do
@project
.
create_or_update_import_data
(
data:
import_data
[
:data
],
credentials:
import_data
[
:credentials
])
if
import_data
if
@project
.
save
&&
!
@project
.
import?
if
@project
.
save
&&
!
@project
.
import?
&&
!
@project
.
bare_repository_import?
raise
'Failed to create repository'
unless
@project
.
create_repository
end
end
...
...
@@ -166,7 +165,7 @@ module Projects
def
import_schedule
if
@project
.
errors
.
empty?
@project
.
import_schedule
if
@project
.
import?
&&
!
@skip_import
@project
.
import_schedule
if
@project
.
import?
else
fail
(
error:
@project
.
errors
.
full_messages
.
join
(
', '
))
end
...
...
lib/gitlab/bare_repository_import/importer.rb
View file @
f2d4b24a
...
...
@@ -56,8 +56,7 @@ module Gitlab
path:
project_name
,
skip_disk_validation:
true
,
skip_wiki:
bare_repo
.
wiki_exists?
,
skip_import:
true
,
import_type:
'gitlab_project'
,
import_type:
'bare_repository'
,
namespace_id:
group
&
.
id
).
execute
if
project
.
persisted?
&&
mv_repo
(
project
)
...
...
spec/lib/gitlab/bare_repository_import/importer_spec.rb
View file @
f2d4b24a
...
...
@@ -169,7 +169,7 @@ describe Gitlab::BareRepositoryImport::Importer, repository: true do
FileUtils
.
mkdir_p
(
File
.
join
(
base_dir
,
"
#{
project_path
}
.wiki.git"
))
expect
(
Projects
::
CreateService
).
to
receive
(
:new
).
with
(
admin
,
hash_including
(
skip_wiki:
true
,
skip_import:
true
)).
and_call_original
import_type:
'bare_repository'
)).
and_call_original
importer
.
create_project_if_needed
...
...
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