2018-07-25 05:30:33 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-28 09:17:42 -04:00
|
|
|
class ForkNetwork < ApplicationRecord
|
2017-09-28 10:38:12 -04:00
|
|
|
belongs_to :root_project, class_name: 'Project'
|
|
|
|
has_many :fork_network_members
|
2018-04-18 09:41:42 -04:00
|
|
|
has_many :projects, through: :fork_network_members
|
2017-09-28 10:38:12 -04:00
|
|
|
|
|
|
|
after_create :add_root_as_member, if: :root_project
|
|
|
|
|
|
|
|
def add_root_as_member
|
|
|
|
projects << root_project
|
|
|
|
end
|
2017-10-03 11:06:09 -04:00
|
|
|
|
|
|
|
def find_forks_in(other_projects)
|
|
|
|
projects.where(id: other_projects)
|
|
|
|
end
|
2017-11-03 06:31:29 -04:00
|
|
|
|
|
|
|
def merge_requests
|
|
|
|
MergeRequest.where(target_project: projects)
|
|
|
|
end
|
2017-09-28 09:34:09 -04:00
|
|
|
end
|