gitlab-org--gitlab-foss/app/services/ci/create_project_service.rb

31 lines
795 B
Ruby
Raw Normal View History

2015-08-25 21:42:46 -04:00
module Ci
class CreateProjectService
include Gitlab::Application.routes.url_helpers
2015-09-16 05:43:16 -04:00
def execute(current_user, params, forked_project = nil)
2015-08-25 21:42:46 -04:00
@project = Ci::Project.parse(params)
Ci::Project.transaction do
@project.save!
2015-09-11 07:38:37 -04:00
gl_project = ::Project.find(@project.gitlab_id)
gl_project.build_missing_services
2015-09-24 10:25:40 -04:00
gl_project.gitlab_ci_service.update_attributes(active: true)
2015-08-25 21:42:46 -04:00
end
if forked_project
# Copy settings
settings = forked_project.attributes.select do |attr_name, value|
["public", "shared_runners_enabled", "allow_git_fetch"].include? attr_name
end
@project.update(settings)
end
Ci::EventService.new.create_project(current_user, @project)
@project
end
end
end