Skip to content
Browse files

Added config option to keep repos in _site. On by default.

  • Loading branch information...
1 parent 7d88f72 commit 2aac8b8a5fcdbc16da168a4e27367f063e91713f @parkr parkr committed May 20, 2012
Showing with 19 additions and 2 deletions.
  1. +4 −0 bin/jekyll
  2. +1 −0 lib/jekyll.rb
  3. +5 −2 lib/jekyll/site.rb
  4. +9 −0 test/test_site.rb
View
4 bin/jekyll
@@ -141,6 +141,10 @@ opts = OptionParser.new do |opts|
options['url'] = url
end
+ opts.on("--keep-repos FALSE", "Whether to delete Git, SVN or Mercurial repository in site destination") do
+ options['keep_repos'] = false
+ end
+
opts.on("--version", "Display current version") do
puts "Jekyll " + Jekyll::VERSION
exit 0
View
1 lib/jekyll.rb
@@ -59,6 +59,7 @@ module Jekyll
'source' => Dir.pwd,
'destination' => File.join(Dir.pwd, '_site'),
'plugins' => File.join(Dir.pwd, '_plugins'),
+ 'keep_repos' => true,
'future' => true,
'lsi' => false,
View
7 lib/jekyll/site.rb
@@ -5,7 +5,8 @@ module Jekyll
class Site
attr_accessor :config, :layouts, :posts, :pages, :static_files,
:categories, :exclude, :include, :source, :dest, :lsi, :pygments,
- :permalink_style, :tags, :time, :future, :safe, :plugins, :limit_posts
+ :permalink_style, :tags, :time, :future, :safe, :plugins, :limit_posts,
+ :keep_repos
attr_accessor :converters, :generators
@@ -26,6 +27,7 @@ def initialize(config)
self.include = config['include'] || []
self.future = config['future']
self.limit_posts = config['limit_posts'] || nil
+ self.keep_repos = config['keep_repos']
self.reset
self.setup
@@ -217,7 +219,8 @@ def cleanup
# all files and directories in destination, including hidden ones
dest_files = Set.new
Dir.glob(File.join(self.dest, "**", "*"), File::FNM_DOTMATCH) do |file|
- dest_files << file unless file =~ /\/\.{1,2}$/
+ pattern = (self.keep_repos ? /\/\.{1,2}(git|hg|svn)?$/ : /\/\.{1,2}$/)
+ dest_files << file unless file =~ pattern
end
# files to be written
View
9 test/test_site.rb
@@ -180,13 +180,19 @@ class TestSite < Test::Unit::TestCase
File.open(dest_dir('qux/obsolete.html'), 'w')
# empty directory
FileUtils.mkdir(dest_dir('quux'))
+ FileUtils.mkdir(dest_dir('.git'))
+ FileUtils.mkdir(dest_dir('.svn'))
+ FileUtils.mkdir(dest_dir('.hg'))
end
teardown do
FileUtils.rm_f(dest_dir('.htpasswd'))
FileUtils.rm_f(dest_dir('obsolete.html'))
FileUtils.rm_rf(dest_dir('qux'))
FileUtils.rm_f(dest_dir('quux'))
+ FileUtils.rm_rf(dest_dir('.git'))
+ FileUtils.rm_rf(dest_dir('.svn'))
+ FileUtils.rm_rf(dest_dir('.hg'))
end
should 'remove orphaned files in destination' do
@@ -195,6 +201,9 @@ class TestSite < Test::Unit::TestCase
assert !File.exist?(dest_dir('obsolete.html'))
assert !File.exist?(dest_dir('qux'))
assert !File.exist?(dest_dir('quux'))
+ assert File.exist?(dest_dir('.git'))
+ assert File.exist?(dest_dir('.svn'))
+ assert File.exist?(dest_dir('.hg'))
end
end

0 comments on commit 2aac8b8

Please sign in to comment.
Something went wrong with that request. Please try again.