diff options
author | Olaf Tomalka <olaf.tomalka@gmail.com> | 2016-09-06 10:52:42 +0200 |
---|---|---|
committer | Olaf Tomalka <olaf.tomalka@gmail.com> | 2016-09-06 10:52:42 +0200 |
commit | 3aa40153e08c959878ba5430d9700935a5195e48 (patch) | |
tree | aea38ea12c10dfdbfe27a1eb1811c598ac11f1c8 /lib | |
parent | bad3fb895cad46c52575aa91b02f7e7786634a47 (diff) | |
download | gitlab-ce-3aa40153e08c959878ba5430d9700935a5195e48.tar.gz |
Improved code quality on API fork namespace feature
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/projects.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb index d35ec73c8c1..5284d1d2305 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -199,18 +199,21 @@ module API post 'fork/:id' do attrs = {} namespace_id = params[:namespace] + if namespace_id.present? namespace = Namespace.find_by(id: namespace_id) || Namespace.find_by_path_or_name(namespace_id) - if namespace.nil? - not_found!('Target Namespace') - end + + not_found!('Target Namespace') unless namespace authorize! :create_projects, namespace + attrs[:namespace] = namespace end + @forked_project = ::Projects::ForkService.new(user_project, current_user, attrs).execute + if @forked_project.errors.any? conflict!(@forked_project.errors.messages) else |