BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
583ed0eb
Unverified
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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
5 deletions
+15
-5
project_import.rb
lib/api/project_import.rb
+13
-3
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
resource
:projects
,
requirements:
{
id:
%r{[^/]+}
}
do
params
do
params
do
requires
:path
,
type:
String
,
desc:
'The new project path and name'
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.'
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'
requires
:file
,
type:
File
,
desc:
'The project export file to be imported'
end
end
resource
:projects
do
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