Class: Projects::TransferService

Inherits:
BaseService show all
Includes:
Gitlab::ShellAdapter
Defined in:
app/services/projects/transfer_service.rb

Constant Summary collapse

TransferError =
Class.new(StandardError)

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from Gitlab::ShellAdapter

#gitlab_shell

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#execute(new_namespace) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/services/projects/transfer_service.rb', line 16

def execute(new_namespace)
  @new_namespace = new_namespace

  if @new_namespace.blank?
    raise TransferError, s_('TransferProject|Please select a new namespace for your project.')
  end

  unless allowed_transfer?(current_user, project)
    raise TransferError, s_('TransferProject|Transfer failed, please contact an admin.')
  end

  transfer(project)

  current_user.invalidate_personal_projects_count

  true
rescue Projects::TransferService::TransferError => ex
  project.reset
  project.errors.add(:new_namespace, ex.message)
  false
end