Commit 35882e68 authored by Tiago Botelho's avatar Tiago Botelho

Adds option to push over SSH to create a new project

parent 921d2afc
...@@ -12,7 +12,7 @@ class Projects::GitHttpController < Projects::GitHttpClientController ...@@ -12,7 +12,7 @@ class Projects::GitHttpController < Projects::GitHttpClientController
log_user_activity if upload_pack? log_user_activity if upload_pack?
if project.blank? && params[:service] == 'git-receive-pack' if project.blank? && params[:service] == 'git-receive-pack'
@project = ::Projects::CreateService.new(access_actor, project_params).execute @project = ::Projects::CreateService.new(user, project_params).execute
return render_ok if @project.saved? return render_ok if @project.saved?
end end
...@@ -34,10 +34,10 @@ class Projects::GitHttpController < Projects::GitHttpClientController ...@@ -34,10 +34,10 @@ class Projects::GitHttpController < Projects::GitHttpClientController
def project_params def project_params
{ {
description: "", description: "",
path: params[:project_id].gsub("\.git", ''), path: params[:project_id].gsub("\.git", ''),
namespace_id: namespace.id.to_s, namespace_id: namespace.id.to_s,
visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s
} }
end end
......
...@@ -43,7 +43,7 @@ module API ...@@ -43,7 +43,7 @@ module API
access_checker_klass = wiki? ? Gitlab::GitAccessWiki : Gitlab::GitAccess access_checker_klass = wiki? ? Gitlab::GitAccessWiki : Gitlab::GitAccess
access_checker = access_checker_klass access_checker = access_checker_klass
.new(actor, project, protocol, authentication_abilities: ssh_authentication_abilities, redirected_path: redirected_path) .new(actor, project, protocol, authentication_abilities: ssh_authentication_abilities, redirected_path: redirected_path, target_namespace: user.namespace)
begin begin
access_checker.check(params[:action], params[:changes]) access_checker.check(params[:action], params[:changes])
...@@ -51,6 +51,19 @@ module API ...@@ -51,6 +51,19 @@ module API
return { status: false, message: e.message } return { status: false, message: e.message }
end end
if project.blank? && params[:action] == 'git-receive-pack'
project_params = {
description: "",
path: params[:project].split('/').last.gsub("\.git", ''),
namespace_id: user.namespace.id.to_s,
visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s
}
@project = ::Projects::CreateService.new(user, project_params).execute
return { status: false, message: "Could not create project" } unless @project.saved?
end
log_user_activity(actor) log_user_activity(actor)
{ {
......
...@@ -250,7 +250,7 @@ module Gitlab ...@@ -250,7 +250,7 @@ module Gitlab
def can_create_project_in_namespace? def can_create_project_in_namespace?
return unless target_namespace return unless target_namespace
actor.can?(:create_projects, target_namespace) user.can?(:create_projects, target_namespace)
end end
def http? def http?
......
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