debian-mirror-gitlab/app/services/projects/create_from_template_service.rb

21 lines
481 B
Ruby
Raw Normal View History

2017-09-10 17:25:29 +05:30
module Projects
class CreateFromTemplateService < BaseService
def initialize(user, params)
@current_user, @params = user, params.dup
end
def execute
2018-03-27 19:54:05 +05:30
template_name = params.delete(:template_name)
file = Gitlab::ProjectTemplate.find(template_name).file
2018-05-09 12:01:36 +05:30
override_params = params.dup
2018-03-27 19:54:05 +05:30
params[:file] = file
2018-05-09 12:01:36 +05:30
GitlabProjectsImportService.new(current_user, params, override_params).execute
2017-09-10 17:25:29 +05:30
ensure
2018-03-27 19:54:05 +05:30
file&.close
2017-09-10 17:25:29 +05:30
end
end
end