Class: Gitlab::ImportExport::RepoRestorer

Inherits:
Object
  • Object
show all
Includes:
CommandLineUtil
Defined in:
lib/gitlab/import_export/repo_restorer.rb

Direct Known Subclasses

DesignRepoRestorer, SnippetRepoRestorer

Constant Summary

Constants included from CommandLineUtil

CommandLineUtil::CLEAN_DIR_IGNORE_FILE_NAMES, CommandLineUtil::CommandLineUtilError, CommandLineUtil::DEFAULT_DIR_MODE, CommandLineUtil::FileOversizedError, CommandLineUtil::HardLinkError, CommandLineUtil::UNTAR_MASK

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CommandLineUtil

#gunzip, #gzip, #gzip_with_options, #mkdir_p, #tar_cf, #tar_czf, #untar_xf, #untar_zxf

Constructor Details

#initialize(importable:, shared:, path_to_bundle:) ⇒ RepoRestorer

Returns a new instance of RepoRestorer.



10
11
12
13
14
# File 'lib/gitlab/import_export/repo_restorer.rb', line 10

def initialize(importable:, shared:, path_to_bundle:)
  @path_to_bundle = path_to_bundle
  @shared = shared
  @importable = importable
end

Instance Attribute Details

#importableObject (readonly)

Returns the value of attribute importable.



8
9
10
# File 'lib/gitlab/import_export/repo_restorer.rb', line 8

def importable
  @importable
end

Instance Method Details

#repositoryObject



30
31
32
# File 'lib/gitlab/import_export/repo_restorer.rb', line 30

def repository
  @repository ||= importable.repository
end

#restoreObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gitlab/import_export/repo_restorer.rb', line 16

def restore
  return true unless File.exist?(path_to_bundle)

  ensure_repository_does_not_exist!

  repository.create_from_bundle(path_to_bundle)
  update_importable_repository_info

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