2020-02-20 04:09:13 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ForkTargetsFinder
|
|
|
|
def initialize(project, user)
|
|
|
|
@project = project
|
|
|
|
@user = user
|
|
|
|
end
|
|
|
|
|
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2020-08-20 20:10:44 -04:00
|
|
|
def execute(options = {})
|
2022-01-18 16:16:02 -05:00
|
|
|
return ::Namespace.where(id: user.forkable_namespaces).sort_by_type unless options[:only_groups]
|
2020-08-20 20:10:44 -04:00
|
|
|
|
2022-01-18 16:16:02 -05:00
|
|
|
::Group.where(id: user.manageable_groups(include_groups_with_developer_maintainer_access: true))
|
2020-02-20 04:09:13 -05:00
|
|
|
end
|
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
attr_reader :project, :user
|
|
|
|
end
|
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
ForkTargetsFinder.prepend_mod_with('ForkTargetsFinder')
|