blob: 1c6629cf9428fc8949308885e01f60c98b0f4efe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# frozen_string_literal: true
module Gitlab
module ImportExport
class RepoRestorer
include Gitlab::ImportExport::CommandLineUtil
attr_reader :importable
def initialize(importable:, shared:, path_to_bundle:)
@path_to_bundle = path_to_bundle
@shared = shared
@importable = importable
end
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
def repository
@repository ||= importable.repository
end
private
attr_accessor :path_to_bundle, :shared
def update_importable_repository_info
# No-op. Overridden in EE
end
def ensure_repository_does_not_exist!
if repository.exists?
shared.logger.info(
message: %Q{Deleting existing "#{repository.disk_path}" to re-import it.}
)
Repositories::DestroyService.new(repository).execute
end
end
end
end
end
Gitlab::ImportExport::RepoRestorer.prepend_mod_with('Gitlab::ImportExport::RepoRestorer')
|