1# frozen_string_literal: true 2 3class MergeRequestTargetProjectFinder 4 include FinderMethods 5 6 attr_reader :current_user, :source_project 7 8 def initialize(current_user: nil, source_project:, project_feature: :merge_requests) 9 @current_user = current_user 10 @source_project = source_project 11 @project_feature = project_feature 12 end 13 14 def execute(include_routes: false) 15 if source_project.fork_network 16 include_routes ? projects.inc_routes : projects 17 else 18 Project.id_in(source_project.id) 19 end 20 end 21 22 private 23 24 attr_reader :project_feature 25 26 def projects 27 source_project 28 .fork_network 29 .projects 30 .public_or_visible_to_user(current_user) 31 .non_archived 32 .with_feature_available_for_user(project_feature, current_user) 33 end 34end 35