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

29 lines
833 B
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
module Projects
class ForkService < BaseService
def execute
2015-09-11 14:41:01 +05:30
new_params = {
forked_from_project_id: @project.id,
visibility_level: @project.visibility_level,
description: @project.description,
name: @project.name,
path: @project.path,
namespace_id: @params[:namespace].try(:id) || current_user.namespace.id
2015-04-26 12:48:37 +05:30
}
2015-09-11 14:41:01 +05:30
if @project.avatar.present? && @project.avatar.image?
new_params[:avatar] = @project.avatar
2015-04-26 12:48:37 +05:30
end
2015-09-11 14:41:01 +05:30
new_project = CreateService.new(current_user, new_params).execute
2015-04-26 12:48:37 +05:30
2015-09-11 14:41:01 +05:30
if new_project.persisted?
if @project.gitlab_ci?
2015-09-25 12:07:36 +05:30
@project.gitlab_ci_service.fork_registration(new_project, @current_user)
2014-09-02 18:07:02 +05:30
end
end
2015-09-11 14:41:01 +05:30
new_project
2014-09-02 18:07:02 +05:30
end
end
end