Commit 10fac475277f469556ddc3ef274743d8776eae74

Authored by Dmitriy Zaporozhets
2 parents 9fa94cad cb6a86ed

Merge branch 'wiki_backup' of /home/git/repositories/gitlab/gitlabhq

app/models/gollum_wiki.rb
@@ -45,6 +45,10 @@ class GollumWiki @@ -45,6 +45,10 @@ class GollumWiki
45 end 45 end
46 end 46 end
47 47
  48 + def empty?
  49 + pages.empty?
  50 + end
  51 +
48 # Returns an Array of Gitlab WikiPage instances or an 52 # Returns an Array of Gitlab WikiPage instances or an
49 # empty Array if this Wiki has no pages. 53 # empty Array if this Wiki has no pages.
50 def pages 54 def pages
lib/backup/repository.rb
@@ -28,7 +28,9 @@ module Backup @@ -28,7 +28,9 @@ module Backup
28 28
29 if File.exists?(path_to_repo(wiki)) 29 if File.exists?(path_to_repo(wiki))
30 print " * #{wiki.path_with_namespace} ... " 30 print " * #{wiki.path_with_namespace} ... "
31 - if system("cd #{path_to_repo(wiki)} > /dev/null 2>&1 && git bundle create #{path_to_bundle(wiki)} --all > /dev/null 2>&1") 31 + if wiki.empty?
  32 + puts " [SKIPPED]".cyan
  33 + elsif system("cd #{path_to_repo(wiki)} > /dev/null 2>&1 && git bundle create #{path_to_bundle(wiki)} --all > /dev/null 2>&1")
32 puts " [DONE]".green 34 puts " [DONE]".green
33 else 35 else
34 puts " [FAILED]".red 36 puts " [FAILED]".red
spec/models/gollum_wiki_spec.rb
@@ -86,6 +86,27 @@ describe GollumWiki do @@ -86,6 +86,27 @@ describe GollumWiki do
86 end 86 end
87 end 87 end
88 88
  89 + describe "#empty?" do
  90 + context "when the wiki repository is empty" do
  91 + before do
  92 + Gitlab::Shell.any_instance.stub(:add_repository) do
  93 + create_temp_repo("#{Rails.root}/tmp/test-git-base-path/non-existant.wiki.git")
  94 + end
  95 + project.stub(:path_with_namespace).and_return("non-existant")
  96 + end
  97 +
  98 + its(:empty?) { should be_true }
  99 + end
  100 +
  101 + context "when the wiki has pages" do
  102 + before do
  103 + create_page("index", "This is an awesome new Gollum Wiki")
  104 + end
  105 +
  106 + its(:empty?) { should be_false }
  107 + end
  108 + end
  109 +
89 describe "#pages" do 110 describe "#pages" do
90 before do 111 before do
91 create_page("index", "This is an awesome new Gollum Wiki") 112 create_page("index", "This is an awesome new Gollum Wiki")