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
Boxiang Sun
gitlab-ce
Commits
a4b6707e
Commit
a4b6707e
authored
Jul 06, 2018
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor manifest import code
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
85b0240c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
17 deletions
+12
-17
app/controllers/import/manifest_controller.rb
app/controllers/import/manifest_controller.rb
+1
-1
doc/user/project/import/img/manifest_upload.png
doc/user/project/import/img/manifest_upload.png
+0
-0
doc/user/project/import/manifest.md
doc/user/project/import/manifest.md
+1
-1
lib/gitlab/manifest_import/project_creator.rb
lib/gitlab/manifest_import/project_creator.rb
+8
-12
spec/lib/gitlab/import_sources_spec.rb
spec/lib/gitlab/import_sources_spec.rb
+1
-2
spec/lib/gitlab/manifest_import/project_creator_spec.rb
spec/lib/gitlab/manifest_import/project_creator_spec.rb
+1
-1
No files found.
app/controllers/import/manifest_controller.rb
View file @
a4b6707e
...
@@ -47,7 +47,7 @@ class Import::ManifestController < Import::BaseController
...
@@ -47,7 +47,7 @@ class Import::ManifestController < Import::BaseController
project
[
:id
]
==
params
[
:repo_id
].
to_i
project
[
:id
]
==
params
[
:repo_id
].
to_i
end
end
project
=
Gitlab
::
ManifestImport
::
Importe
r
.
new
(
repository
,
group
,
current_user
).
execute
project
=
Gitlab
::
ManifestImport
::
ProjectCreato
r
.
new
(
repository
,
group
,
current_user
).
execute
if
project
.
persisted?
if
project
.
persisted?
render
json:
ProjectSerializer
.
new
.
represent
(
project
)
render
json:
ProjectSerializer
.
new
.
represent
(
project
)
...
...
doc/user/project/import/img/manifest_upload.png
View replaced file @
85b0240c
View file @
a4b6707e
17 KB
|
W:
|
H:
11.3 KB
|
W:
|
H:
2-up
Swipe
Onion skin
doc/user/project/import/manifest.md
View file @
a4b6707e
...
@@ -10,7 +10,7 @@ You can do it by following next steps:
...
@@ -10,7 +10,7 @@ You can do it by following next steps:
1.
Click on the
**Manifest file**
button
1.
Click on the
**Manifest file**
button
1.
Provide GitLab with a manifest xml file
1.
Provide GitLab with a manifest xml file
1.
Select a group you want to import to (you need to create a group first if you don't have one)
1.
Select a group you want to import to (you need to create a group first if you don't have one)
1.
Click
**
Import projects
**
1.
Click
**
Continue to the next step
**
1.
You will be redirected to the import status page with projects list based on manifest file
1.
You will be redirected to the import status page with projects list based on manifest file
1.
Check the list and click 'Import all repositories' to start import.
1.
Check the list and click 'Import all repositories' to start import.
...
...
lib/gitlab/manifest_import/
importe
r.rb
→
lib/gitlab/manifest_import/
project_creato
r.rb
View file @
a4b6707e
module
Gitlab
module
Gitlab
module
ManifestImport
module
ManifestImport
class
Importe
r
class
ProjectCreato
r
attr_reader
:repository
,
:destination
,
:user
attr_reader
:repository
,
:destination
,
:
current_
user
def
initialize
(
repository
,
destination
,
user
)
def
initialize
(
repository
,
destination
,
current_
user
)
@repository
=
repository
@repository
=
repository
@destination
=
destination
@destination
=
destination
@
user
=
user
@
current_user
=
current_
user
end
end
def
execute
def
execute
import_project
end
private
def
import_project
group_full_path
,
_
,
project_path
=
repository
[
:path
].
rpartition
(
'/'
)
group_full_path
,
_
,
project_path
=
repository
[
:path
].
rpartition
(
'/'
)
group_full_path
=
File
.
join
(
destination
.
full_path
,
group_full_path
)
if
destination
group_full_path
=
File
.
join
(
destination
.
full_path
,
group_full_path
)
if
destination
group
=
Group
.
find_by_full_path
(
group_full_path
)
||
group
=
Group
.
find_by_full_path
(
group_full_path
)
||
...
@@ -30,16 +24,18 @@ module Gitlab
...
@@ -30,16 +24,18 @@ module Gitlab
visibility_level:
destination
.
visibility_level
visibility_level:
destination
.
visibility_level
}
}
Projects
::
CreateService
.
new
(
user
,
params
).
execute
Projects
::
CreateService
.
new
(
current_
user
,
params
).
execute
end
end
private
def
create_group_with_parents
(
full_path
)
def
create_group_with_parents
(
full_path
)
params
=
{
params
=
{
group_path:
full_path
,
group_path:
full_path
,
visibility_level:
destination
.
visibility_level
visibility_level:
destination
.
visibility_level
}
}
Groups
::
NestedCreateService
.
new
(
user
,
params
).
execute
Groups
::
NestedCreateService
.
new
(
current_
user
,
params
).
execute
end
end
end
end
end
end
...
...
spec/lib/gitlab/import_sources_spec.rb
View file @
a4b6707e
...
@@ -50,7 +50,6 @@ describe Gitlab::ImportSources do
...
@@ -50,7 +50,6 @@ describe Gitlab::ImportSources do
fogbugz
fogbugz
gitlab_project
gitlab_project
gitea
gitea
manifest
)
)
expect
(
described_class
.
importer_names
).
to
eq
(
expected
)
expect
(
described_class
.
importer_names
).
to
eq
(
expected
)
...
@@ -67,7 +66,7 @@ describe Gitlab::ImportSources do
...
@@ -67,7 +66,7 @@ describe Gitlab::ImportSources do
'git'
=>
nil
,
'git'
=>
nil
,
'gitlab_project'
=>
Gitlab
::
ImportExport
::
Importer
,
'gitlab_project'
=>
Gitlab
::
ImportExport
::
Importer
,
'gitea'
=>
Gitlab
::
LegacyGithubImport
::
Importer
,
'gitea'
=>
Gitlab
::
LegacyGithubImport
::
Importer
,
'manifest'
=>
Gitlab
::
ManifestImport
::
Importer
'manifest'
=>
nil
}
}
import_sources
.
each
do
|
name
,
klass
|
import_sources
.
each
do
|
name
,
klass
|
...
...
spec/lib/gitlab/manifest_import/
importe
r_spec.rb
→
spec/lib/gitlab/manifest_import/
project_creato
r_spec.rb
View file @
a4b6707e
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
ManifestImport
::
Importe
r
,
:postgresql
do
describe
Gitlab
::
ManifestImport
::
ProjectCreato
r
,
:postgresql
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:repository
)
do
let
(
:repository
)
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