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
583ed0eb
Commit
583ed0eb
authored
Feb 13, 2018
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add import status endpoint
parent
7ec1a022
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
10 deletions
+20
-10
lib/api/project_import.rb
lib/api/project_import.rb
+18
-8
spec/requests/api/project_import_spec.rb
spec/requests/api/project_import_spec.rb
+2
-2
No files found.
lib/api/project_import.rb
View file @
583ed0eb
...
@@ -16,12 +16,13 @@ module API
...
@@ -16,12 +16,13 @@ module API
not_found!
unless
Gitlab
::
CurrentSettings
.
import_sources
.
include?
(
'gitlab_project'
)
not_found!
unless
Gitlab
::
CurrentSettings
.
import_sources
.
include?
(
'gitlab_project'
)
end
end
params
do
resource
:projects
,
requirements:
{
id:
%r{[^/]+}
}
do
requires
:path
,
type:
String
,
desc:
'The new project path and name'
optional
:namespace
,
type:
String
,
desc:
'The ID or name of the namespace that the project will be imported into. Defaults to the user namespace.'
params
do
requires
:file
,
type:
File
,
desc:
'The project export file to be imported'
requires
:path
,
type:
String
,
desc:
'The new project path and name'
end
optional
:namespace
,
type:
String
,
desc:
'The ID or name of the namespace that the project will be imported into. Defaults to the user namespace.'
resource
:projects
do
requires
:file
,
type:
File
,
desc:
'The project export file to be imported'
end
desc
'Get export status'
do
desc
'Get export status'
do
success
Entities
::
ProjectImportStatus
success
Entities
::
ProjectImportStatus
end
end
...
@@ -40,13 +41,22 @@ module API
...
@@ -40,13 +41,22 @@ module API
project_params
=
import_params
.
merge
(
namespace_id:
namespace
.
id
,
project_params
=
import_params
.
merge
(
namespace_id:
namespace
.
id
,
file:
import_params
[
:file
][
'tempfile'
])
file:
import_params
[
:file
][
'tempfile'
])
project
=
::
Projects
::
GitlabProjectsImportService
.
new
(
current_user
,
project_params
).
execute
project
=
::
Projects
::
GitlabProjectsImportService
.
new
(
current_user
,
project_params
).
execute
render_api_error!
(
project
.
full_messages
.
first
,
400
)
unless
project
.
saved?
render_api_error!
(
project
&
.
full_messages
&
.
first
,
400
)
unless
project
&
.
saved?
present
project
,
with:
Entities
::
ProjectImportStatus
present
project
,
with:
Entities
::
ProjectImportStatus
end
end
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
desc
'Get export status'
do
success
Entities
::
ProjectImportStatus
end
get
':id/import'
do
present
user_project
,
with:
Entities
::
ProjectImportStatus
end
end
end
end
end
end
end
spec/requests/api/project_import_spec.rb
View file @
583ed0eb
...
@@ -22,14 +22,13 @@ describe API::ProjectImport do
...
@@ -22,14 +22,13 @@ describe API::ProjectImport do
post
api
(
'/projects/import'
,
user
),
path:
'test-import'
,
file:
fixture_file_upload
(
file
),
namespace:
namespace
.
full_path
post
api
(
'/projects/import'
,
user
),
path:
'test-import'
,
file:
fixture_file_upload
(
file
),
namespace:
namespace
.
full_path
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
Project
.
find_by_name
(
'test-import'
).
first
.
status
).
to
eq
(
'started'
)
end
end
end
end
describe
'GET /projects/:id/import'
do
describe
'GET /projects/:id/import'
do
it
'returns the import status'
do
it
'returns the import status'
do
project
=
create
(
:project
,
import_status:
'started'
)
project
=
create
(
:project
,
import_status:
'started'
)
project
.
add_master
(
user
)
get
api
(
"/projects/
#{
project
.
id
}
/import"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/import"
,
user
)
...
@@ -39,6 +38,7 @@ describe API::ProjectImport do
...
@@ -39,6 +38,7 @@ describe API::ProjectImport do
it
'returns the import status and the error if failed'
do
it
'returns the import status and the error if failed'
do
project
=
create
(
:project
,
import_status:
'failed'
,
import_error:
'error'
)
project
=
create
(
:project
,
import_status:
'failed'
,
import_error:
'error'
)
project
.
add_master
(
user
)
get
api
(
"/projects/
#{
project
.
id
}
/import"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/import"
,
user
)
...
...
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