Commit ec394d49 authored by James Lopez's avatar James Lopez

add some more comments

parent d8252efe
module Gitlab module Gitlab
module ImportExport module ImportExport
# Given a class, it finds or creates a new object # Given a class, it finds or creates a new object
# (initializes in the case of Label) at group or project level # (initializes in the case of Label) at group or project level.
# If it does not exist in the group, it creates it at project level # If it does not exist in the group, it creates it at project level.
# #
# For example: # Example:
# `GroupProjectObjectBuilder.build(Label, label_attributes)` # `GroupProjectObjectBuilder.build(Label, label_attributes)`
# finds or initializes a label with the given attributes. # finds or initializes a label with the given attributes.
# #
# It also adds some logic around Group Labels/Milestones for edge cases. # It also adds some logic around Group Labels/Milestones for edge cases.
class GroupProjectObjectBuilder class GroupProjectObjectBuilder
...@@ -88,6 +88,8 @@ module Gitlab ...@@ -88,6 +88,8 @@ module Gitlab
# - Importing into a user namespace project with exported group milestones # - Importing into a user namespace project with exported group milestones
# where the IID of the Group milestone could conflict with a project one. # where the IID of the Group milestone could conflict with a project one.
def claim_iid def claim_iid
# The milestone has to be a group milestone, as it's the only case where
# we set the IID as the maximum. The rest of them are fixed.
group_milestone = @project.milestones.find_by(iid: @attributes['iid']) group_milestone = @project.milestones.find_by(iid: @attributes['iid'])
group_milestone.update!(iid: max_milestone_iid + 1) if group_milestone group_milestone.update!(iid: max_milestone_iid + 1) if group_milestone
......
...@@ -78,6 +78,9 @@ module Gitlab ...@@ -78,6 +78,9 @@ module Gitlab
@restored_project = Project.find(@project_id) @restored_project = Project.find(@project_id)
end end
# Remove project models that became group models as we found them at group level.
# This no longer required saving them at the root project level.
# For example, in the case of an existing group label that matched the title.
def remove_group_models(relation_hash) def remove_group_models(relation_hash)
relation_hash.reject! do |value| relation_hash.reject! do |value|
value.respond_to?(:group_id) && value.group_id && GROUP_MODELS.include?(value.class) value.respond_to?(:group_id) && value.group_id && GROUP_MODELS.include?(value.class)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment