From 825614067a5496fcef722d19df109eee476877c1 Mon Sep 17 00:00:00 2001 From: David Danzilio Date: Thu, 7 Apr 2016 17:25:39 -0400 Subject: [PATCH] Handling existing doc directory --- lib/puppet-strings/rake_tasks.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/puppet-strings/rake_tasks.rb b/lib/puppet-strings/rake_tasks.rb index 5a9cec7..eda4b5c 100644 --- a/lib/puppet-strings/rake_tasks.rb +++ b/lib/puppet-strings/rake_tasks.rb @@ -21,7 +21,14 @@ namespace :strings do desc "Checkout the gh-pages branch for doc generation." task :checkout do - unless Dir.exist?('doc') + if Dir.exist?('doc') + fail "The 'doc' directory (#{File.expand_path('doc')}) is not a Git repository! Remove it and run the Rake task again." unless Dir.exist?('doc/.git') + Dir.chdir('doc') do + system 'git checkout gh-pages' + system 'git reset --hard origin/gh-pages' + system 'git pull origin gh-pages' + end + else Dir.mkdir('doc') Dir.chdir('doc') do system 'git init'