From 32b2ff26011a5274bdb8a3dd41ad360a67c3148a Mon Sep 17 00:00:00 2001 From: Tiago Botelho Date: Fri, 19 Jan 2018 13:04:14 +0000 Subject: Adds remote messsage when project is created in a push over SSH or HTTP --- app/controllers/projects/git_http_controller.rb | 38 +++++++++++++++---------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'app/controllers/projects/git_http_controller.rb') diff --git a/app/controllers/projects/git_http_controller.rb b/app/controllers/projects/git_http_controller.rb index 97c0f5b8c87..6010423c243 100644 --- a/app/controllers/projects/git_http_controller.rb +++ b/app/controllers/projects/git_http_controller.rb @@ -11,10 +11,14 @@ class Projects::GitHttpController < Projects::GitHttpClientController def info_refs log_user_activity if upload_pack? - if project.blank? && params[:service] == 'git-receive-pack' + if user && project.blank? && receive_pack? @project = ::Projects::CreateService.new(user, project_params).execute - return render_ok if @project.saved? + if @project.saved? + Gitlab::Checks::NewProject.new(user, @project, 'http').add_new_project_message + else + raise Gitlab::GitAccess::NotFoundError, 'Could not create project' + end end render_ok @@ -32,15 +36,6 @@ class Projects::GitHttpController < Projects::GitHttpClientController private - def project_params - { - description: "", - path: params[:project_id].gsub("\.git", ''), - namespace_id: namespace.id.to_s, - visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s - } - end - def download_request? upload_pack? end @@ -49,6 +44,10 @@ class Projects::GitHttpController < Projects::GitHttpClientController git_command == 'git-upload-pack' end + def receive_pack? + git_command == 'git-receive-pack' + end + def git_command if action_name == 'info_refs' params[:service] @@ -74,10 +73,6 @@ class Projects::GitHttpController < Projects::GitHttpClientController @access ||= access_klass.new(access_actor, project, 'http', authentication_abilities: authentication_abilities, redirected_path: redirected_path, target_namespace: namespace) end - def namespace - @namespace = Namespace.find_by_path_or_name(params[:namespace_id]) - end - def access_actor return user if user return :ci if ci? @@ -93,6 +88,19 @@ class Projects::GitHttpController < Projects::GitHttpClientController @access_klass ||= wiki? ? Gitlab::GitAccessWiki : Gitlab::GitAccess end + def project_params + { + description: "", + path: Project.parse_project_id(params[:project_id]), + namespace_id: namespace&.id, + visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s + } + end + + def namespace + @namespace ||= Namespace.find_by_path_or_name(params[:namespace_id]) + end + def log_user_activity Users::ActivityService.new(user, 'pull').execute end -- cgit v1.2.1