Commit 191aa971 authored by Achilleas Pipinellis's avatar Achilleas Pipinellis

Properly fix wiki restore.

ProjectWiki.new() creates a new wiki git repository, so any tries
to bare clone a bundle fail. With this patch we remove the newly
created wiki.git before restoring from the backup bundle.
parent 31f75603
...@@ -59,7 +59,7 @@ module Backup ...@@ -59,7 +59,7 @@ module Backup
FileUtils.mkdir_p(repos_path) FileUtils.mkdir_p(repos_path)
Project.find_each(batch_size: 1000) do |project| Project.find_each(batch_size: 1000) do |project|
$progress.print "#{project.path_with_namespace} ... " $progress.print " * #{project.path_with_namespace} ... "
project.namespace.ensure_dir_exist if project.namespace project.namespace.ensure_dir_exist if project.namespace
...@@ -79,13 +79,14 @@ module Backup ...@@ -79,13 +79,14 @@ module Backup
wiki = ProjectWiki.new(project) wiki = ProjectWiki.new(project)
if File.exists?(path_to_bundle(wiki))
$progress.print " * #{wiki.path_with_namespace} ... " $progress.print " * #{wiki.path_with_namespace} ... "
if File.exists?(path_to_bundle(wiki)) # If a wiki bundle exists, first remove the empty repo
# that was initialized with ProjectWiki.new() and then
# try to restore with 'git clone --bare'.
FileUtils.rm_rf(path_to_repo(wiki))
cmd = %W(git clone --bare #{path_to_bundle(wiki)} #{path_to_repo(wiki)}) cmd = %W(git clone --bare #{path_to_bundle(wiki)} #{path_to_repo(wiki)})
else
cmd = %W(git init --bare #{path_to_repo(wiki)})
end
if system(*cmd, silent) if system(*cmd, silent)
$progress.puts " [DONE]".green $progress.puts " [DONE]".green
...@@ -95,6 +96,7 @@ module Backup ...@@ -95,6 +96,7 @@ module Backup
abort 'Restore failed' abort 'Restore failed'
end end
end end
end
$progress.print 'Put GitLab hooks in repositories dirs'.yellow $progress.print 'Put GitLab hooks in repositories dirs'.yellow
cmd = "#{Gitlab.config.gitlab_shell.path}/bin/create-hooks" cmd = "#{Gitlab.config.gitlab_shell.path}/bin/create-hooks"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment