Skip to content

Loading…

Adding two new test cases for exclude configuration use cases. #2303

Merged
merged 2 commits into from

4 participants

@parkr
Jekyll member

Extension of #2046, not excluding an item from the list of files if it starts with one of the excluded items.

Closes #2046.

/cc @jbranchaud

@parkr
Jekyll member

@benbalter You ran into frustrations with the exclude key recently – what do you think of these changes?

@parkr parkr added this to the 2.0 milestone
@mattr-
Jekyll member

Also LGTM. :shipit:

@parkr parkr merged commit 6c1bb76 into master

1 check passed

Details continuous-integration/travis-ci The Travis CI build passed
@parkr parkr deleted the jbranchaud-adding_exclude_tests branch
@parkr parkr added a commit that referenced this pull request
@parkr parkr Update history to reflect merge of #2303 [ci skip] 1f94ca7
@benbalter

My frustration was around excluding /vendor without excluding /assets/vendor. Not sure if this fixes that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 17 additions and 3 deletions.
  1. +1 −3 lib/jekyll/entry_filter.rb
  2. +16 −0 test/test_entry_filter.rb
View
4 lib/jekyll/entry_filter.rb
@@ -65,9 +65,7 @@ def glob_include?(enum, e)
entry = ensure_leading_slash(e)
enum.any? do |exp|
item = ensure_leading_slash(exp)
- Jekyll.logger.debug "glob_include?(#{entry})"
- Jekyll.logger.debug " ==> File.fnmatch?(#{item}, #{entry}) == #{File.fnmatch?(item, entry)}"
- File.fnmatch?(item, entry)
+ File.fnmatch?(item, entry) || entry.start_with?(item)
end
end
end
View
16 test/test_entry_filter.rb
@@ -25,6 +25,22 @@ class TestEntryFilter < Test::Unit::TestCase
assert_equal files, @site.filter_entries(excludes + files + ["excludeA"])
end
+ should "filter entries with exclude relative to site source" do
+ excludes = %w[README TODO css]
+ files = %w[index.html vendor/css .htaccess]
+
+ @site.exclude = excludes
+ assert_equal files, @site.filter_entries(excludes + files + ["css"])
+ end
+
+ should "filter excluded directory and contained files" do
+ excludes = %w[README TODO css]
+ files = %w[index.html .htaccess]
+
+ @site.exclude = excludes
+ assert_equal files, @site.filter_entries(excludes + files + ["css", "css/main.css", "css/vendor.css"])
+ end
+
should "not filter entries within include" do
includes = %w[_index.html .htaccess include*]
files = %w[index.html _index.html .htaccess includeA]
Something went wrong with that request. Please try again.