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
c3de6a86
Commit
c3de6a86
authored
Jun 24, 2018
by
Aram Visser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add transfer project endpoint to the Projects API
parent
2452f1a7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
0 deletions
+64
-0
changelogs/unreleased/transfer_project_api_endpoint.yml
changelogs/unreleased/transfer_project_api_endpoint.yml
+5
-0
doc/api/projects.md
doc/api/projects.md
+10
-0
lib/api/projects.rb
lib/api/projects.rb
+17
-0
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+32
-0
No files found.
changelogs/unreleased/transfer_project_api_endpoint.yml
0 → 100644
View file @
c3de6a86
---
title
:
Add transfer project API endpoint
merge_request
:
20122
author
:
Aram Visser
type
:
added
doc/api/projects.md
View file @
c3de6a86
...
@@ -1390,6 +1390,16 @@ POST /projects/:id/housekeeping
...
@@ -1390,6 +1390,16 @@ POST /projects/:id/housekeeping
| --------- | ---- | -------- | ----------- |
| --------- | ---- | -------- | ----------- |
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
|
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
|
### Transfer a project to a new namespace
```
PUT /projects/:id/transfer
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`namespace`
| integer/string | yes | The ID or path of the namespace to transfer to project to |
## Branches
## Branches
Read more in the
[
Branches
](
branches.md
)
documentation.
Read more in the
[
Branches
](
branches.md
)
documentation.
...
...
lib/api/projects.rb
View file @
c3de6a86
...
@@ -459,6 +459,23 @@ module API
...
@@ -459,6 +459,23 @@ module API
conflict!
(
error
.
message
)
conflict!
(
error
.
message
)
end
end
end
end
desc
'Transfer a project to a new namespace'
params
do
requires
:namespace
,
type:
String
,
desc:
'The ID or path of the new namespace'
end
put
":id/transfer"
do
authorize!
:change_namespace
,
user_project
namespace
=
find_namespace!
(
params
[
:namespace
])
result
=
::
Projects
::
TransferService
.
new
(
user_project
,
current_user
).
execute
(
namespace
)
if
result
present
user_project
,
with:
Entities
::
Project
else
render_api_error!
(
"Failed to transfer project
#{
user_project
.
errors
.
messages
}
"
,
400
)
end
end
end
end
end
end
end
end
spec/requests/api/projects_spec.rb
View file @
c3de6a86
...
@@ -1990,6 +1990,38 @@ describe API::Projects do
...
@@ -1990,6 +1990,38 @@ describe API::Projects do
end
end
end
end
describe
'PUT /projects/:id/transfer'
do
context
'when authenticated as owner'
do
let
(
:group
)
{
create
:group
}
it
'transfers the project to the new namespace'
do
group
.
add_owner
(
user
)
put
api
(
"/projects/
#{
project
.
id
}
/transfer"
,
user
),
namespace:
group
.
id
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
it
'fails when transferring to a non owned namespace'
do
put
api
(
"/projects/
#{
project
.
id
}
/transfer"
,
user
),
namespace:
group
.
id
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
it
'fails when transferring to an unknown namespace'
do
put
api
(
"/projects/
#{
project
.
id
}
/transfer"
,
user
),
namespace:
'unknown'
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
it
'fails on missing namespace'
do
put
api
(
"/projects/
#{
project
.
id
}
/transfer"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
end
end
end
it_behaves_like
'custom attributes endpoints'
,
'projects'
do
it_behaves_like
'custom attributes endpoints'
,
'projects'
do
let
(
:attributable
)
{
project
}
let
(
:attributable
)
{
project
}
let
(
:other_attributable
)
{
project2
}
let
(
:other_attributable
)
{
project2
}
...
...
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