From d94c91220962864815f97d781846766e0e108738 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Fri, 18 Jan 2019 21:37:38 +0530 Subject: [PATCH 1/2] Filter out exclusively excluded entries sooner --- lib/jekyll/entry_filter.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/jekyll/entry_filter.rb b/lib/jekyll/entry_filter.rb index 95f95c2a7c0..390017bd124 100644 --- a/lib/jekyll/entry_filter.rb +++ b/lib/jekyll/entry_filter.rb @@ -31,13 +31,20 @@ def relative_to_source(entry) def filter(entries) entries.reject do |e| - # Reject this entry if it is a symlink. + # Check if the current entry is explicitly included and cache the result + included = included?(e) + + # Reject current entry if it is excluded but not explicitly included as well. + next true if excluded?(e) && !included + + # Reject current entry if it is a symlink. next true if symlink?(e) - # Do not reject this entry if it is included. - next false if included?(e) - # Reject this entry if it is special, a backup file, or excluded. - special?(e) || backup?(e) || excluded?(e) + # Do not reject current entry if it is explicitly included. + next false if included + + # Reject current entry if it is special or a backup file. + special?(e) || backup?(e) end end From e58c19e43ce727f49593d695bc40dcde87fb1b7f Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Fri, 7 Feb 2020 19:47:27 +0530 Subject: [PATCH 2/2] Test if this breaks existing workflow --- test/test_entry_filter.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/test_entry_filter.rb b/test/test_entry_filter.rb index b3d820e0693..45500dd2cf7 100644 --- a/test/test_entry_filter.rb +++ b/test/test_entry_filter.rb @@ -64,6 +64,16 @@ class TestEntryFilter < JekyllUnitTest assert_equal files, @site.reader.filter_entries(files) end + should "not exclude explicitly included entry" do + entries = %w(README TODO css .htaccess _movies/.) + excludes = %w(README TODO css) + includes = %w(README .htaccess) + @site.exclude = excludes + @site.include = includes + filtered_entries = EntryFilter.new(@site).filter(entries) + assert_equal %w(README .htaccess), filtered_entries + end + should "keep safe symlink entries when safe mode enabled" do allow(File).to receive(:symlink?).with("symlink.js").and_return(true) files = %w(symlink.js)