mojombo/jekyll — pull request #535 by jameskilton (2012-04-04 03:26:45+00:00)
Title: Add source and destination directory protection

After accidentally telling jekyll to use my source directory as it's destination directory, and losing work because it also deleted my `.git` directory and all other hidden files, I updated the library to take steps to prevent this from happening again.

First was to remove the dot-file deletion entirely from the cleanup of the site. This is a potentially very dangerous action that's impossible to test that it's correct. If the '..' check line ever disappears, even running the tests will attempt to delete everything accessible on the person's computer.

From what I can tell, all generated dot-files will already be known by Jekyll, and any static files will be configured for Jekyll to include, so it should properly remove all the files that it already knows about.

With this changed, I've also added a check on site generation that the destination directory doesn't include, or isn't exactly the same as, the source directory. While this isn't 100% fool proof, you'd need to use some symlinking to still cause an unfortunate destruction of your source files, this should cover almost all cases people would normally run into.

This is the results of discussion in #534 among others.