2016-04-15 16:14:28 +00:00
|
|
|
module Gitlab
|
|
|
|
module ImportExport
|
|
|
|
class RepoRestorer
|
|
|
|
include Gitlab::ImportExport::CommandLineUtil
|
2017-02-13 15:43:17 +00:00
|
|
|
include Gitlab::ShellAdapter
|
2016-04-15 16:14:28 +00:00
|
|
|
|
2016-07-18 09:02:07 +00:00
|
|
|
def initialize(project:, shared:, path_to_bundle:)
|
2016-04-15 16:14:28 +00:00
|
|
|
@project = project
|
2016-05-05 10:39:18 +00:00
|
|
|
@path_to_bundle = path_to_bundle
|
2016-05-11 15:22:45 +00:00
|
|
|
@shared = shared
|
2016-04-15 16:14:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def restore
|
2016-07-18 09:02:07 +00:00
|
|
|
return true unless File.exist?(@path_to_bundle)
|
2016-04-15 16:14:28 +00:00
|
|
|
|
2017-02-13 15:43:17 +00:00
|
|
|
gitlab_shell.import_repository(@project.repository_storage_path, @project.path_with_namespace, @path_to_bundle)
|
2016-05-11 15:22:45 +00:00
|
|
|
rescue => e
|
2016-05-13 10:33:13 +00:00
|
|
|
@shared.error(e)
|
2016-05-05 11:19:41 +00:00
|
|
|
false
|
2016-04-15 16:14:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|