debian-mirror-gitlab/app/finders/merge_request_target_project_finder.rb

34 lines
775 B
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
class MergeRequestTargetProjectFinder
2018-03-27 19:54:05 +05:30
include FinderMethods
2018-03-17 18:26:18 +05:30
attr_reader :current_user, :source_project
def initialize(current_user: nil, source_project:)
@current_user = current_user
@source_project = source_project
end
2018-12-05 23:21:45 +05:30
# rubocop: disable CodeReuse/ActiveRecord
2020-01-01 13:55:28 +05:30
def execute(include_routes: false)
if source_project.fork_network
include_routes ? projects.inc_routes : projects
2018-03-17 18:26:18 +05:30
else
Project.where(id: source_project)
end
end
2018-12-05 23:21:45 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2020-01-01 13:55:28 +05:30
private
def projects
source_project
.fork_network
.projects
.public_or_visible_to_user(current_user)
.non_archived
.with_feature_available_for_user(:merge_requests, current_user)
end
2018-03-17 18:26:18 +05:30
end