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

#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?, #can_all?, #can_any?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#execute(fork_to_project = nil) ⇒ Object



5
6
7
8
9
10
11
# File 'app/services/projects/fork_service.rb', line 5

def execute(fork_to_project = nil)
  response = fork_to_project ? link_existing_project(fork_to_project) : fork_new_project

  after_fork(response[:project]) if response.success?

  response
end

#valid_fork_branch?(branch) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/services/projects/fork_service.rb', line 17

def valid_fork_branch?(branch)
  @project.repository.branch_exists?(branch)
end

#valid_fork_target?(namespace = target_namespace) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
# File 'app/services/projects/fork_service.rb', line 21

def valid_fork_target?(namespace = target_namespace)
  return true if current_user.admin?

  valid_fork_targets.include?(namespace)
end

#valid_fork_targets(options = {}) ⇒ Object



13
14
15
# File 'app/services/projects/fork_service.rb', line 13

def valid_fork_targets(options = {})
  @valid_fork_targets ||= ForkTargetsFinder.new(@project, current_user).execute(options)
end