summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-01-18 16:07:07 +0000
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-02-06 13:35:35 +0000
commit35882e681b681f68a818bda9a8d2624edfecc219 (patch)
tree0688bc4a1f770c1be480c412b4553522aefe9878
parent921d2afc6989dfa8220032984f657210c07e8792 (diff)
downloadgitlab-ce-35882e681b681f68a818bda9a8d2624edfecc219.tar.gz
Adds option to push over SSH to create a new project
-rw-r--r--app/controllers/projects/git_http_controller.rb10
-rw-r--r--lib/api/internal.rb15
-rw-r--r--lib/gitlab/git_access.rb2
3 files changed, 20 insertions, 7 deletions
diff --git a/app/controllers/projects/git_http_controller.rb b/app/controllers/projects/git_http_controller.rb
index 45a1a5cf0de..97c0f5b8c87 100644
--- a/app/controllers/projects/git_http_controller.rb
+++ b/app/controllers/projects/git_http_controller.rb
@@ -12,7 +12,7 @@ class Projects::GitHttpController < Projects::GitHttpClientController
log_user_activity if upload_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?
end
@@ -34,10 +34,10 @@ class Projects::GitHttpController < Projects::GitHttpClientController
def project_params
{
- description: "",
- path: params[:project_id].gsub("\.git", ''),
- namespace_id: namespace.id.to_s,
- visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s
+ description: "",
+ path: params[:project_id].gsub("\.git", ''),
+ namespace_id: namespace.id.to_s,
+ visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s
}
end
diff --git a/lib/api/internal.rb b/lib/api/internal.rb
index 063f0d6599c..a83f714a1f3 100644
--- a/lib/api/internal.rb
+++ b/lib/api/internal.rb
@@ -43,7 +43,7 @@ module API
access_checker_klass = wiki? ? Gitlab::GitAccessWiki : Gitlab::GitAccess
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
access_checker.check(params[:action], params[:changes])
@@ -51,6 +51,19 @@ module API
return { status: false, message: e.message }
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)
{
diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb
index 9427a5e4baa..7de8a99f9dc 100644
--- a/lib/gitlab/git_access.rb
+++ b/lib/gitlab/git_access.rb
@@ -250,7 +250,7 @@ module Gitlab
def can_create_project_in_namespace?
return unless target_namespace
- actor.can?(:create_projects, target_namespace)
+ user.can?(:create_projects, target_namespace)
end
def http?