Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-01-25 15:26:52 +0300
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-02-06 16:35:35 +0300
commite42a548f1dac02577d0c1731fef508dab68c45a5 (patch)
tree9781b82ec0da58683ebeb0fd0ba2062a9ce10e43 /app/controllers/projects
parentbc78ae6985ee37f9ac2ffc2dbf6f445078d16038 (diff)
Move new project on push logic to a service
Diffstat (limited to 'app/controllers/projects')
-rw-r--r--app/controllers/projects/git_http_controller.rb33
1 files changed, 11 insertions, 22 deletions
diff --git a/app/controllers/projects/git_http_controller.rb b/app/controllers/projects/git_http_controller.rb
index 5660a9027d5..90a9079fab3 100644
--- a/app/controllers/projects/git_http_controller.rb
+++ b/app/controllers/projects/git_http_controller.rb
@@ -5,21 +5,13 @@ class Projects::GitHttpController < Projects::GitHttpClientController
rescue_from Gitlab::GitAccess::UnauthorizedError, with: :render_403
rescue_from Gitlab::GitAccess::NotFoundError, with: :render_404
+ rescue_from Gitlab::GitAccess::ProjectCreationError, with: :render_422
# GET /foo/bar.git/info/refs?service=git-upload-pack (git pull)
# GET /foo/bar.git/info/refs?service=git-receive-pack (git push)
def info_refs
log_user_activity if upload_pack?
-
- if user && project.blank? && receive_pack?
- @project = ::Projects::CreateService.new(user, project_params).execute
-
- 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
+ create_new_project if receive_pack? && project.blank?
render_ok
end
@@ -31,8 +23,6 @@ class Projects::GitHttpController < Projects::GitHttpClientController
# POST /foo/bar.git/git-receive-pack" (git push)
def git_receive_pack
- raise Gitlab::GitAccess::NotFoundError, 'Could not create project' unless project
-
render_ok
end
@@ -58,6 +48,10 @@ class Projects::GitHttpController < Projects::GitHttpClientController
end
end
+ def create_new_project
+ @project = ::Projects::CreateFromPushService.new(user, params[:project_id], namespace, 'http').execute
+ end
+
def render_ok
set_workhorse_internal_api_content_type
render json: Gitlab::Workhorse.git_http_ok(repository, wiki?, user, action_name)
@@ -71,6 +65,10 @@ class Projects::GitHttpController < Projects::GitHttpClientController
render plain: exception.message, status: :not_found
end
+ def render_422(exception)
+ render plain: exception.message, status: :unprocessable_entity
+ end
+
def access
@access ||= access_klass.new(access_actor, project, 'http', authentication_abilities: authentication_abilities, redirected_path: redirected_path, target_namespace: namespace)
end
@@ -90,17 +88,8 @@ 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])
+ @namespace ||= Namespace.find_by_full_path(params[:namespace_id])
end
def log_user_activity