Filter out exclusively excluded entries sooner (#7482)
Merge pull request 7482
This commit is contained in:
parent
bc3b92c151
commit
696e8e4b99
|
@ -28,20 +28,30 @@ module Jekyll
|
|||
)
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/CyclomaticComplexity
|
||||
def filter(entries)
|
||||
entries.reject do |e|
|
||||
# Reject this entry if it is just a "dot" representation.
|
||||
# e.g.: '.', '..', '_movies/.', 'music/..', etc
|
||||
next true if e.end_with?(".")
|
||||
# Reject this 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)
|
||||
# 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 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
|
||||
# rubocop:enable Metrics/CyclomaticComplexity
|
||||
|
||||
def included?(entry)
|
||||
glob_include?(site.include, entry) ||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue