2017-07-26 12:21:53 +00:00
|
|
|
module Projects
|
|
|
|
class CreateFromTemplateService < BaseService
|
|
|
|
def initialize(user, params)
|
|
|
|
@current_user, @params = user, params.dup
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2018-02-12 13:57:25 +00:00
|
|
|
template_name = params.delete(:template_name)
|
|
|
|
file = Gitlab::ProjectTemplate.find(template_name).file
|
|
|
|
|
2018-04-19 15:24:32 +00:00
|
|
|
override_params = params.dup
|
2018-02-12 13:57:25 +00:00
|
|
|
params[:file] = file
|
|
|
|
|
2018-04-19 15:24:32 +00:00
|
|
|
GitlabProjectsImportService.new(current_user, params, override_params).execute
|
2017-07-26 12:21:53 +00:00
|
|
|
|
2017-08-01 12:34:11 +00:00
|
|
|
ensure
|
2018-02-12 13:57:25 +00:00
|
|
|
file&.close
|
2017-07-26 12:21:53 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|