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 45 end
46 46 end
47 47  
  48 + def empty?
  49 + pages.empty?
  50 + end
  51 +
48 52 # Returns an Array of Gitlab WikiPage instances or an
49 53 # empty Array if this Wiki has no pages.
50 54 def pages
... ...
lib/backup/repository.rb
... ... @@ -28,7 +28,9 @@ module Backup
28 28  
29 29 if File.exists?(path_to_repo(wiki))
30 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 34 puts " [DONE]".green
33 35 else
34 36 puts " [FAILED]".red
... ...
spec/models/gollum_wiki_spec.rb
... ... @@ -86,6 +86,27 @@ describe GollumWiki do
86 86 end
87 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 110 describe "#pages" do
90 111 before do
91 112 create_page("index", "This is an awesome new Gollum Wiki")
... ...