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,
|
2015-12-23 02:04:40 +05:30
|
|
|
shared_runners_enabled: @project.shared_runners_enabled,
|
|
|
|
builds_enabled: @project.builds_enabled,
|
2015-09-11 14:41:01 +05:30
|
|
|
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
|
|
|
|
new_project
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|