blob: c1769ea28f9a244ceb32835ab1de28817d76f812 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# frozen_string_literal: true
class ForkTargetsFinder
def initialize(project, user)
@project = project
@user = user
end
def execute(options = {})
items = fork_targets(options)
by_search(items, options)
end
private
attr_reader :project, :user
def by_search(items, options)
return items if options[:search].blank?
items.search(options[:search])
end
def fork_targets(options)
if options[:only_groups]
user.manageable_groups(include_groups_with_developer_maintainer_access: true)
else
user.forkable_namespaces.sort_by_type
end
end
end
ForkTargetsFinder.prepend_mod_with('ForkTargetsFinder')
|