BigW Consortium Gitlab

fork_network.rb 454 Bytes
Newer Older
1
class ForkNetwork < ActiveRecord::Base
2 3 4 5 6 7 8 9 10
  belongs_to :root_project, class_name: 'Project'
  has_many :fork_network_members
  has_many :projects, through: :fork_network_members

  after_create :add_root_as_member, if: :root_project

  def add_root_as_member
    projects << root_project
  end
11 12 13 14

  def find_forks_in(other_projects)
    projects.where(id: other_projects)
  end
15 16 17 18

  def merge_requests
    MergeRequest.where(target_project: projects)
  end
19
end