summaryrefslogtreecommitdiff
path: root/lib/api/helpers/internal_helpers.rb
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-01-25 12:26:52 +0000
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-02-06 13:35:35 +0000
commite42a548f1dac02577d0c1731fef508dab68c45a5 (patch)
tree9781b82ec0da58683ebeb0fd0ba2062a9ce10e43 /lib/api/helpers/internal_helpers.rb
parentbc78ae6985ee37f9ac2ffc2dbf6f445078d16038 (diff)
downloadgitlab-ce-e42a548f1dac02577d0c1731fef508dab68c45a5.tar.gz
Move new project on push logic to a service
Diffstat (limited to 'lib/api/helpers/internal_helpers.rb')
-rw-r--r--lib/api/helpers/internal_helpers.rb29
1 files changed, 7 insertions, 22 deletions
diff --git a/lib/api/helpers/internal_helpers.rb b/lib/api/helpers/internal_helpers.rb
index fd568c5ef30..2340e962918 100644
--- a/lib/api/helpers/internal_helpers.rb
+++ b/lib/api/helpers/internal_helpers.rb
@@ -29,10 +29,6 @@ module API
{}
end
- def receive_pack?
- params[:action] == 'git-receive-pack'
- end
-
def fix_git_env_repository_paths(env, repository_path)
if obj_dir_relative = env['GIT_OBJECT_DIRECTORY_RELATIVE'].presence
env['GIT_OBJECT_DIRECTORY'] = File.join(repository_path, obj_dir_relative)
@@ -51,6 +47,10 @@ module API
::Users::ActivityService.new(actor, 'Git SSH').execute if commands.include?(params[:action])
end
+ def receive_pack?
+ params[:action] == 'git-receive-pack'
+ end
+
def merge_request_urls
::MergeRequests::GetUrlsService.new(project).execute(params[:changes])
end
@@ -64,29 +64,14 @@ module API
false
end
- def project_params
- {
- description: "",
- path: Project.parse_project_id(project_match[:project_id]),
- namespace_id: project_namespace&.id,
- visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s
- }
+ def project_namespace
+ @project_namespace ||= project&.namespace || Namespace.find_by_full_path(project_match[:namespace_path])
end
private
- def project_path_regex
- @project_regex ||= /\A(?<namespace_id>#{Gitlab::PathRegex.full_namespace_route_regex})\/(?<project_id>#{Gitlab::PathRegex.project_git_route_regex})\z/.freeze
- end
-
def project_match
- @project_match ||= params[:project].match(project_path_regex)
- end
-
- def project_namespace
- return unless project_match
-
- @project_namespace ||= Namespace.find_by_path_or_name(project_match[:namespace_id])
+ @project_match ||= params[:project].match(Gitlab::PathRegex.full_project_git_path_regex)
end
# rubocop:disable Gitlab/ModuleWithInstanceVariables