Class: Gitlab::ImportExport::Group::TreeRestorer

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/import_export/group/tree_restorer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(user:, shared:, group:) ⇒ TreeRestorer

Returns a new instance of TreeRestorer.


11
12
13
14
15
16
# File 'lib/gitlab/import_export/group/tree_restorer.rb', line 11

def initialize(user:, shared:, group:)
  @user = user
  @shared = shared
  @top_level_group = group
  @groups_mapping = {}
end

Instance Attribute Details

#sharedObject (readonly)

Returns the value of attribute shared


9
10
11
# File 'lib/gitlab/import_export/group/tree_restorer.rb', line 9

def shared
  @shared
end

#userObject (readonly)

Returns the value of attribute user


9
10
11
# File 'lib/gitlab/import_export/group/tree_restorer.rb', line 9

def user
  @user
end

Instance Method Details

#restoreObject


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gitlab/import_export/group/tree_restorer.rb', line 18

def restore
  group_ids = relation_reader.consume_relation('groups', '_all').map { |value, _idx| Integer(value) }
  root_group_id = group_ids.delete_at(0)

  process_root(root_group_id)

  group_ids.each do |group_id|
    process_child(group_id)
  end

  true
rescue => e
  shared.error(e)
  false
end