2013-03-19 11:37:50 -04:00
|
|
|
module Projects
|
2014-01-16 12:03:42 -05:00
|
|
|
class ForkService < BaseService
|
2013-03-19 11:37:50 -04:00
|
|
|
def execute
|
2015-04-24 15:37:12 -04:00
|
|
|
new_params = {
|
|
|
|
forked_from_project_id: @project.id,
|
|
|
|
visibility_level: @project.visibility_level,
|
|
|
|
description: @project.description,
|
|
|
|
name: @project.name,
|
|
|
|
path: @project.path,
|
2015-12-04 06:55:23 -05:00
|
|
|
shared_runners_enabled: @project.shared_runners_enabled,
|
|
|
|
builds_enabled: @project.builds_enabled,
|
2015-04-24 15:37:12 -04:00
|
|
|
namespace_id: @params[:namespace].try(:id) || current_user.namespace.id
|
2014-08-25 05:19:52 -04:00
|
|
|
}
|
|
|
|
|
2015-04-24 15:37:12 -04:00
|
|
|
if @project.avatar.present? && @project.avatar.image?
|
|
|
|
new_params[:avatar] = @project.avatar
|
2014-10-03 04:12:44 -04:00
|
|
|
end
|
2014-11-13 12:40:47 -05:00
|
|
|
|
2015-04-24 15:37:12 -04:00
|
|
|
new_project = CreateService.new(current_user, new_params).execute
|
|
|
|
new_project
|
2013-05-02 15:30:13 -04:00
|
|
|
end
|
2013-03-19 11:37:50 -04:00
|
|
|
end
|
|
|
|
end
|