Dest match #1556

Merged
merged 3 commits into from Sep 17, 2013

Projects

None yet

3 participants

@maul-esel
Contributor

As noted in #1130, jekyll's current matching of source and destination (to ensure that the source is not inside the destination) is too aggressive, meaning that a source of blog-source and a destination of blog will cause the generation to halt. This is because it uses a simple regex for checking.

This PR changes the relevant code to use Pathname instead, and also adds an extensive cucumber feature to test the behaviour. This fixes the described issue.

@parkr parkr commented on the diff Sep 16, 2013
lib/jekyll/site.rb
@@ -83,6 +79,17 @@ def setup
self.generators = instantiate_subclasses(Jekyll::Generator)
end
+ # Check that the destination dir isn't the source dir or a directory
+ # parent to the source dir.
+ def ensure_not_in_dest
+ dest = Pathname.new(self.dest)
+ Pathname.new(self.source).ascend do |path|
@parkr
parkr Sep 16, 2013 Member

How efficient is Pathname#ascend?

@mattr-
mattr- Sep 17, 2013 Member

as efficient as working with strings, since that's what most of Pathname does anyways.

@parkr parkr commented on the diff Sep 16, 2013
features/step_definitions/jekyll_steps.rb
@@ -137,10 +137,14 @@
File.delete(file)
end
-Then /^the (.*) directory should exist$/ do |dir|
+Then /^the (.*) directory should +exist$/ do |dir|
@parkr
Member
parkr commented Sep 16, 2013

This looks pretty good to me! @mattr-?

Thanks @maul-esel!

@mattr- mattr- merged commit de49342 into jekyll:master Sep 17, 2013

1 check passed

default The Travis CI build passed
Details
@mattr- mattr- added a commit that referenced this pull request Sep 17, 2013
@mattr- mattr- Update history to reflect merge of #1556 bff0f9e
@maul-esel maul-esel deleted the maul-esel:dest-match branch Sep 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment