diff options
author | Bernhard Kaindl <bkl@use.startmail.com> | 2014-10-01 10:20:40 +0200 |
---|---|---|
committer | Bernhard Kaindl <bkl@use.startmail.com> | 2014-10-01 10:27:48 +0200 |
commit | f030ee846ed39c5e0a326e8ba117ec79f40e230d (patch) | |
tree | 8e95dbeb3720fc5805d9f70b765cedfad199f2d2 /lib | |
parent | 88d3e97e502f0be4f01fed100a06e04b2e0f2017 (diff) | |
download | gitlab-ce-f030ee846ed39c5e0a326e8ba117ec79f40e230d.tar.gz |
API: Initial support for forking a project via the API
This change adds POST /projects/fork/:id to the API for forking
a project into the namespace of the authenticated user, like the
"create fork" link in the GUI does. It also calls the same code.
Failure and permission checks (except for conflict) are already
implemented and handled in ForkService and the API, so the added
code is simple and does not alter anything.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/projects.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb index f555819df1b..7f7d2f8e9a8 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -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: |