diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-09-28 16:38:12 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-07 11:46:23 +0200 |
commit | d328007214786c7137c31d2c73e9ee76b025e6ed (patch) | |
tree | fe4ec118148b7397890f86c6b2982ce667086c38 /app/models/fork_network.rb | |
parent | 20727db1702849b78e6714197f16f602f68cecf8 (diff) | |
download | gitlab-ce-d328007214786c7137c31d2c73e9ee76b025e6ed.tar.gz |
Create a fork network when forking a project
When no fork network exists for the source projects, we create a new
one with the correct source
Diffstat (limited to 'app/models/fork_network.rb')
-rw-r--r-- | app/models/fork_network.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/fork_network.rb b/app/models/fork_network.rb index 60c8c167b21..fd2510d0a4c 100644 --- a/app/models/fork_network.rb +++ b/app/models/fork_network.rb @@ -1,3 +1,11 @@ class ForkNetwork < ActiveRecord::Base - belongs_to :root_project + 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 end |