summaryrefslogtreecommitdiff
path: root/app/controllers/projects/git_http_controller.rb
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-01-19 13:04:14 +0000
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-02-06 13:35:35 +0000
commit32b2ff26011a5274bdb8a3dd41ad360a67c3148a (patch)
tree56064e3de4e9ca505730bdf1af3597ba8ead499f /app/controllers/projects/git_http_controller.rb
parent35882e681b681f68a818bda9a8d2624edfecc219 (diff)
downloadgitlab-ce-32b2ff26011a5274bdb8a3dd41ad360a67c3148a.tar.gz
Adds remote messsage when project is created in a push over SSH or HTTP
Diffstat (limited to 'app/controllers/projects/git_http_controller.rb')
-rw-r--r--app/controllers/projects/git_http_controller.rb38
1 files changed, 23 insertions, 15 deletions
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