summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/gollum_wiki.rb4
-rw-r--r--lib/backup/repository.rb4
-rw-r--r--spec/models/gollum_wiki_spec.rb21
3 files changed, 28 insertions, 1 deletions
diff --git a/app/models/gollum_wiki.rb b/app/models/gollum_wiki.rb
index d1edbab4533..05fc2a745b4 100644
--- a/app/models/gollum_wiki.rb
+++ b/app/models/gollum_wiki.rb
@@ -45,6 +45,10 @@ class GollumWiki
end
end
+ def empty?
+ pages.empty?
+ end
+
# Returns an Array of Gitlab WikiPage instances or an
# empty Array if this Wiki has no pages.
def pages
diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb
index c5e3d049fd7..252201f11be 100644
--- a/lib/backup/repository.rb
+++ b/lib/backup/repository.rb
@@ -28,7 +28,9 @@ module Backup
if File.exists?(path_to_repo(wiki))
print " * #{wiki.path_with_namespace} ... "
- if system("cd #{path_to_repo(wiki)} > /dev/null 2>&1 && git bundle create #{path_to_bundle(wiki)} --all > /dev/null 2>&1")
+ if wiki.empty?
+ puts " [SKIPPED]".cyan
+ elsif system("cd #{path_to_repo(wiki)} > /dev/null 2>&1 && git bundle create #{path_to_bundle(wiki)} --all > /dev/null 2>&1")
puts " [DONE]".green
else
puts " [FAILED]".red
diff --git a/spec/models/gollum_wiki_spec.rb b/spec/models/gollum_wiki_spec.rb
index aa850dfd0a3..9e07d9ee191 100644
--- a/spec/models/gollum_wiki_spec.rb
+++ b/spec/models/gollum_wiki_spec.rb
@@ -86,6 +86,27 @@ describe GollumWiki do
end
end
+ describe "#empty?" do
+ context "when the wiki repository is empty" do
+ before do
+ Gitlab::Shell.any_instance.stub(:add_repository) do
+ create_temp_repo("#{Rails.root}/tmp/test-git-base-path/non-existant.wiki.git")
+ end
+ project.stub(:path_with_namespace).and_return("non-existant")
+ end
+
+ its(:empty?) { should be_true }
+ end
+
+ context "when the wiki has pages" do
+ before do
+ create_page("index", "This is an awesome new Gollum Wiki")
+ end
+
+ its(:empty?) { should be_false }
+ end
+ end
+
describe "#pages" do
before do
create_page("index", "This is an awesome new Gollum Wiki")