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
12
13
14
# 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

  if forked_project&.saved?
    refresh_forks_count
    stream_audit_event(forked_project)
  end

  forked_project
end

#valid_fork_target?(namespace = target_namespace) ⇒ Boolean

Returns:

  • (Boolean)


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

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

  valid_fork_targets.include?(namespace)
end

#valid_fork_targets(options = {}) ⇒ Object



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

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