Commit 3ad4f552 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '37222-extract-ee-after_create_actions' into 'master'

Extract methods to EE::Projects::CreateService

Closes gitlab-ce#37222

See merge request !2831
parents e26d0f5e 2dea07dc
......@@ -28,9 +28,6 @@ module Projects
return @project
end
# EE-only: Repository size limit comes as MB from the view
set_repository_size_limit_as_bytes
set_project_name_from_path
# get namespace id
......@@ -107,11 +104,6 @@ module Projects
system_hook_service.execute_hooks_for(@project, :create)
setup_authorizations
# EE-only
create_predefined_push_rule
@project.group&.refresh_members_authorized_projects
end
# Refresh the current user's authorizations inline (so they can access the
......@@ -161,11 +153,6 @@ module Projects
end
end
def set_repository_size_limit_as_bytes
limit = params.delete(:repository_size_limit)
@project.repository_size_limit = Gitlab::Utils.try_megabytes_to_bytes(limit) if limit
end
def set_project_name_from_path
# Set project name from path
if @project.name.present? && @project.path.present?
......@@ -179,16 +166,5 @@ module Projects
@project.path = @project.name.dup.parameterize
end
end
def create_predefined_push_rule
return unless project.feature_available?(:push_rules)
predefined_push_rule = PushRule.find_by(is_sample: true)
if predefined_push_rule
push_rule = predefined_push_rule.dup.tap { |gh| gh.is_sample = false }
project.push_rule = push_rule
end
end
end
end
......@@ -4,11 +4,15 @@ module EE
def execute
raise NotImplementedError unless defined?(super)
limit = params.delete(:repository_size_limit)
mirror = params.delete(:mirror)
mirror_user_id = params.delete(:mirror_user_id)
mirror_trigger_builds = params.delete(:mirror_trigger_builds)
super do |project|
# Repository size limit comes as MB from the view
project.repository_size_limit = ::Gitlab::Utils.try_megabytes_to_bytes(limit) if limit
if mirror && project.feature_available?(:repository_mirrors)
project.mirror = mirror unless mirror.nil?
project.mirror_trigger_builds = mirror_trigger_builds unless mirror_trigger_builds.nil?
......@@ -16,6 +20,29 @@ module EE
end
end
end
private
def after_create_actions
raise NotImplementedError unless defined?(super)
super
create_predefined_push_rule
@project.group&.refresh_members_authorized_projects
end
def create_predefined_push_rule
return unless project.feature_available?(:push_rules)
predefined_push_rule = PushRule.find_by(is_sample: true)
if predefined_push_rule
push_rule = predefined_push_rule.dup.tap { |gh| gh.is_sample = false }
project.push_rule = push_rule
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment