2016-04-15 16:14:28 +00:00
|
|
|
module Gitlab
|
|
|
|
module ImportExport
|
|
|
|
class RepoRestorer
|
|
|
|
include Gitlab::ImportExport::CommandLineUtil
|
|
|
|
|
2016-06-02 12:44:59 +00:00
|
|
|
def initialize(project:, shared:, path_to_bundle:, wiki: false)
|
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-06-02 12:44:59 +00:00
|
|
|
@wiki = wiki
|
2016-04-15 16:14:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def restore
|
2016-06-13 13:33:28 +00:00
|
|
|
return false unless File.exist?(@path_to_bundle) || wiki?
|
2016-04-15 16:14:28 +00:00
|
|
|
|
|
|
|
FileUtils.mkdir_p(path_to_repo)
|
2016-05-05 10:39:18 +00:00
|
|
|
|
2016-05-05 12:21:27 +00:00
|
|
|
git_unbundle(repo_path: path_to_repo, bundle_path: @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
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def repos_path
|
|
|
|
Gitlab.config.gitlab_shell.repos_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def path_to_repo
|
|
|
|
@project.repository.path_to_repo
|
|
|
|
end
|
2016-06-02 12:44:59 +00:00
|
|
|
|
|
|
|
def wiki?
|
|
|
|
@wiki
|
|
|
|
end
|
2016-04-15 16:14:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|