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
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
not_found!
unless
Gitlab
::
CurrentSettings
.
import_sources
.
include?
(
'gitlab_project'
)
end
params
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.'
requires
:file
,
type:
File
,
desc:
'The project export file to be imported'
end
resource
:projects
do
resource
:projects
,
requirements:
{
id:
%r{[^/]+}
}
do
params
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.'
requires
:file
,
type:
File
,
desc:
'The project export file to be imported'
end
desc
'Get export status'
do
success
Entities
::
ProjectImportStatus
end
...
...
@@ -40,13 +41,22 @@ module API
project_params
=
import_params
.
merge
(
namespace_id:
namespace
.
id
,
file:
import_params
[
:file
][
'tempfile'
])
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
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
spec/requests/api/project_import_spec.rb
View file @
583ed0eb
...
...
@@ -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
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
Project
.
find_by_name
(
'test-import'
).
first
.
status
).
to
eq
(
'started'
)
end
end
describe
'GET /projects/:id/import'
do
it
'returns the import status'
do
project
=
create
(
:project
,
import_status:
'started'
)
project
.
add_master
(
user
)
get
api
(
"/projects/
#{
project
.
id
}
/import"
,
user
)
...
...
@@ -39,6 +38,7 @@ describe API::ProjectImport do
it
'returns the import status and the error if failed'
do
project
=
create
(
:project
,
import_status:
'failed'
,
import_error:
'error'
)
project
.
add_master
(
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