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
1099468b
Commit
1099468b
authored
Oct 01, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce
parents
b10774eb
aab2b0bf
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
105 additions
and
0 deletions
+105
-0
CHANGELOG
CHANGELOG
+1
-0
doc/api/projects.md
doc/api/projects.md
+12
-0
doc/workflow/gitlab_flow.md
doc/workflow/gitlab_flow.md
+2
-0
doc/workflow/gitlab_flow.png
doc/workflow/gitlab_flow.png
+0
-0
lib/api/projects.rb
lib/api/projects.rb
+17
-0
spec/requests/api/fork_spec.rb
spec/requests/api/fork_spec.rb
+73
-0
No files found.
CHANGELOG
View file @
1099468b
...
...
@@ -9,6 +9,7 @@ v 7.4.0
- Do not delete tmp/repositories itself during clean-up, only its contents
- Support for backup uploads to remote storage
- Prevent notes polling when there are not notes
- API: Add support for forking a project via the API (Bernhard Kaindl)
- API: filter project issues by milestone (Julien Bianchi)
v 7.3.2
...
...
doc/api/projects.md
View file @
1099468b
...
...
@@ -281,6 +281,18 @@ Parameters:
-
`visibility_level`
(optional)
-
`import_url`
(optional)
### Fork project
Forks a project into the user namespace of the authenticated user.
```
POST /projects/fork/:id
```
Parameters:
-
`id`
(required) - The ID of the project to be forked
### Remove project
Removes a project including all associated resources (issues, merge requests etc.)
...
...
doc/workflow/gitlab_flow.md
View file @
1099468b
![
GitLab Flow
](
gitlab_flow.png
)
# Introduction
Version management with git makes branching and merging much easier than older versioning systems such as SVN.
...
...
doc/workflow/gitlab_flow.png
0 → 100644
View file @
1099468b
88.8 KB
lib/api/projects.rb
View file @
1099468b
...
...
@@ -153,6 +153,23 @@ module API
end
end
# Fork new project for the current user.
#
# Parameters:
# id (required) - The ID of a project
# Example Request
# POST /projects/fork/:id
post
'fork/:id'
do
@forked_project
=
::
Projects
::
ForkService
.
new
(
user_project
,
current_user
).
execute
if
@forked_project
.
errors
.
any?
conflict!
(
@forked_project
.
errors
.
messages
)
else
present
@forked_project
,
with:
Entities
::
Project
end
end
# Remove project
#
# Parameters:
...
...
spec/requests/api/fork_spec.rb
0 → 100644
View file @
1099468b
require
'spec_helper'
describe
API
::
API
,
api:
true
do
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let
(
:user3
)
{
create
(
:user
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
let
(
:project_user2
)
{
create
(
:project_member
,
user:
user2
,
project:
project
,
access_level:
ProjectMember
::
GUEST
)
}
describe
'POST /projects/fork/:id'
do
before
{
project_user2
}
before
{
user3
}
context
'when authenticated'
do
it
'should fork if user has sufficient access to project'
do
post
api
(
"/projects/fork/
#{
project
.
id
}
"
,
user2
)
response
.
status
.
should
==
201
json_response
[
'name'
].
should
==
project
.
name
json_response
[
'path'
].
should
==
project
.
path
json_response
[
'owner'
][
'id'
].
should
==
user2
.
id
json_response
[
'namespace'
][
'id'
].
should
==
user2
.
namespace
.
id
json_response
[
'forked_from_project'
][
'id'
].
should
==
project
.
id
end
it
'should fork if user is admin'
do
post
api
(
"/projects/fork/
#{
project
.
id
}
"
,
admin
)
response
.
status
.
should
==
201
json_response
[
'name'
].
should
==
project
.
name
json_response
[
'path'
].
should
==
project
.
path
json_response
[
'owner'
][
'id'
].
should
==
admin
.
id
json_response
[
'namespace'
][
'id'
].
should
==
admin
.
namespace
.
id
json_response
[
'forked_from_project'
][
'id'
].
should
==
project
.
id
end
it
'should fail on missing project access for the project to fork'
do
post
api
(
"/projects/fork/
#{
project
.
id
}
"
,
user3
)
response
.
status
.
should
==
404
json_response
[
'message'
].
should
==
'404 Not Found'
end
it
'should fail if forked project exists in the user namespace'
do
post
api
(
"/projects/fork/
#{
project
.
id
}
"
,
user
)
response
.
status
.
should
==
409
json_response
[
'message'
][
'base'
].
should
==
[
'Invalid fork destination'
]
json_response
[
'message'
][
'name'
].
should
==
[
'has already been taken'
]
json_response
[
'message'
][
'path'
].
should
==
[
'has already been taken'
]
end
it
'should fail if project to fork from does not exist'
do
post
api
(
'/projects/fork/424242'
,
user
)
response
.
status
.
should
==
404
json_response
[
'message'
].
should
==
'404 Not Found'
end
end
context
'when unauthenticated'
do
it
'should return authentication error'
do
post
api
(
"/projects/fork/
#{
project
.
id
}
"
)
response
.
status
.
should
==
401
json_response
[
'message'
].
should
==
'401 Unauthorized'
end
end
end
end
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