Commit 39f77ad9 authored by Balasankar "Balu" C's avatar Balasankar "Balu" C

Let users set name/path on project fork using API

parent ab9f8785
...@@ -38,8 +38,8 @@ module Projects ...@@ -38,8 +38,8 @@ module Projects
new_params = { new_params = {
visibility_level: allowed_visibility_level, visibility_level: allowed_visibility_level,
description: @project.description, description: @project.description,
name: @project.name, name: target_name,
path: @project.path, path: target_path,
shared_runners_enabled: @project.shared_runners_enabled, shared_runners_enabled: @project.shared_runners_enabled,
namespace_id: target_namespace.id, namespace_id: target_namespace.id,
fork_network: fork_network, fork_network: fork_network,
...@@ -94,6 +94,14 @@ module Projects ...@@ -94,6 +94,14 @@ module Projects
Projects::ForksCountService.new(@project).refresh_cache Projects::ForksCountService.new(@project).refresh_cache
end end
def target_path
@target_path ||= @params[:path] || @project.path
end
def target_name
@target_name ||= @params[:name] || @project.name
end
def target_namespace def target_namespace
@target_namespace ||= @params[:namespace] || current_user.namespace @target_namespace ||= @params[:namespace] || current_user.namespace
end end
......
---
title: Add ability to set path and name for project on fork using API
merge_request: 25363
author:
type: added
...@@ -771,6 +771,8 @@ POST /projects/:id/fork ...@@ -771,6 +771,8 @@ POST /projects/:id/fork
| --------- | ---- | -------- | ----------- | | --------- | ---- | -------- | ----------- |
| `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) |
| `namespace` | integer/string | yes | The ID or path of the namespace that the project will be forked to | | `namespace` | integer/string | yes | The ID or path of the namespace that the project will be forked to |
| `path` | string | no | The path that will be assigned to the resultant project after forking |
| `name` | string | no | The name that will be assigned to the resultant project after forking |
## List Forks of a project ## List Forks of a project
......
...@@ -258,6 +258,8 @@ module API ...@@ -258,6 +258,8 @@ module API
end end
params do params do
optional :namespace, type: String, desc: 'The ID or name of the namespace that the project will be forked into' optional :namespace, type: String, desc: 'The ID or name of the namespace that the project will be forked into'
optional :path, type: String, desc: 'The path that will be assigned to the fork'
optional :name, type: String, desc: 'The name that will be assigned to the fork'
end end
post ':id/fork' do post ':id/fork' do
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42284') Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42284')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment