Class: Projects::ForkService

Inherits:
BaseService show all
Defined in:
app/services/projects/fork_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#abilities, #can?, #deny_visibility_level, #event_service, #initialize, #log_info, #notification_service, #repository, #system_hook_service, #todo_service

Methods included from Gitlab::CurrentSettings

#current_application_settings, #fake_application_settings

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#executeObject


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/services/projects/fork_service.rb', line 3

def execute
  new_params = {
    forked_from_project_id: @project.id,
    visibility_level:       @project.visibility_level,
    description:            @project.description,
    name:                   @project.name,
    path:                   @project.path,
    shared_runners_enabled: @project.shared_runners_enabled,
    builds_enabled:         @project.builds_enabled,
    namespace_id:           @params[:namespace].try(:id) || current_user.namespace.id
  }

  if @project.avatar.present? && @project.avatar.image?
    new_params[:avatar] = @project.avatar
  end

  new_project = CreateService.new(current_user, new_params).execute
  new_project
end