use git bundle in import and add wiki repo to import
This commit is contained in:
parent
43488d277e
commit
92f4bde427
|
@ -23,6 +23,12 @@ module Gitlab
|
||||||
status.zero?
|
status.zero?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def git_unbundle(git_bin_path: Gitlab.config.git.bin_path, repo_path:, bundle_path:)
|
||||||
|
cmd = %W(#{git_bin_path} clone --bare #{bundle_path} #{repo_path})
|
||||||
|
_output, status = Gitlab::Popen.popen(cmd)
|
||||||
|
status.zero?
|
||||||
|
end
|
||||||
|
|
||||||
def tar_with_options(archive:, dir:, options:)
|
def tar_with_options(archive:, dir:, options:)
|
||||||
cmd = %W(tar -#{options} #{archive} -C #{dir} .)
|
cmd = %W(tar -#{options} #{archive} -C #{dir} .)
|
||||||
_output, status = Gitlab::Popen.popen(cmd)
|
_output, status = Gitlab::Popen.popen(cmd)
|
||||||
|
|
|
@ -15,7 +15,7 @@ module Gitlab
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
Gitlab::ImportExport::Importer.import(archive_file: @archive_file, storage_path: storage_path)
|
Gitlab::ImportExport::Importer.import(archive_file: @archive_file, storage_path: storage_path)
|
||||||
project_tree.project if [restore_project_tree, restore_repo].all?
|
project_tree.project if [restore_project_tree, restore_repo, restore_wiki_repo].all?
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -29,7 +29,11 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
def restore_repo
|
def restore_repo
|
||||||
Gitlab::ImportExport::RepoRestorer.new(path: storage_path, project: project_tree.project).restore
|
Gitlab::ImportExport::RepoRestorer.new(path: repo_path, project: project_tree.project).restore
|
||||||
|
end
|
||||||
|
|
||||||
|
def restore_wiki_repo
|
||||||
|
Gitlab::ImportExport::RepoRestorer.new(path: wiki_repo_path, project: project_tree.project).restore
|
||||||
end
|
end
|
||||||
|
|
||||||
def storage_path
|
def storage_path
|
||||||
|
@ -39,6 +43,14 @@ module Gitlab
|
||||||
def path_with_namespace
|
def path_with_namespace
|
||||||
File.join(@namespace.path, @project_path)
|
File.join(@namespace.path, @project_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def repo_path
|
||||||
|
File.join('storage_path', 'project.bundle')
|
||||||
|
end
|
||||||
|
|
||||||
|
def wiki_repo_path
|
||||||
|
File.join('storage_path', 'project.wiki.bundle')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,19 +3,18 @@ module Gitlab
|
||||||
class RepoRestorer
|
class RepoRestorer
|
||||||
include Gitlab::ImportExport::CommandLineUtil
|
include Gitlab::ImportExport::CommandLineUtil
|
||||||
|
|
||||||
def initialize(project:, path:)
|
def initialize(project:, path_to_bundle: )
|
||||||
@project = project
|
@project = project
|
||||||
# TODO remove magic keyword and move it to a shared config
|
@path_to_bundle = path_to_bundle
|
||||||
@path = File.join(path, 'project.bundle')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def restore
|
def restore
|
||||||
return false unless File.exists?(@path)
|
return true unless File.exists?(@path)
|
||||||
# Move repos dir to 'repositories.old' dir
|
|
||||||
|
|
||||||
FileUtils.mkdir_p(repos_path)
|
FileUtils.mkdir_p(repos_path)
|
||||||
FileUtils.mkdir_p(path_to_repo)
|
FileUtils.mkdir_p(path_to_repo)
|
||||||
untar_xf(archive: @path, dir: path_to_repo)
|
|
||||||
|
git_unbundle(git_bin_path: Gitlab.config.git.bin_path, repo_path: path_to_repo, bundle_path: @path_to_bundle)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Reference in New Issue