summaryrefslogtreecommitdiff
path: root/app/finders/merge_request_target_project_finder.rb
blob: f358938344ed55c3d4398945c0cee940ca7b84ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class MergeRequestTargetProjectFinder
  include FinderMethods

  attr_reader :current_user, :source_project

  def initialize(current_user: nil, source_project:)
    @current_user = current_user
    @source_project = source_project
  end

  def execute
    if @source_project.fork_network
      @source_project.fork_network.projects
        .public_or_visible_to_user(current_user)
        .with_feature_available_for_user(:merge_requests, current_user)
    else
      Project.where(id: source_project)
    end
  end
end