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?

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)
  forked_project = fork_to_project ? link_existing_project(fork_to_project) : fork_new_project

  refresh_forks_count if forked_project&.saved?

  forked_project
end

#valid_fork_target?(namespace = target_namespace) ⇒ Boolean

Returns:

  • (Boolean)

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

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