diff --git a/app/models/gollum_wiki.rb b/app/models/gollum_wiki.rb index d1edbab4533afab1e846355c15f275a2560f12b4..05fc2a745b411c03d4a81afda0b3278300cf7787 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 c5e3d049fd77319bb0d545b7b34014948d5d7d4a..252201f11be767f7117a87bbb6191a44cf82afef 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 aa850dfd0a334b16b17452eed366e43e3a2479a7..9e07d9ee191567f4deea3560464bd2694dff0b53 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")