Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix false positive conflicts for static files in a collection #9141

Merged
merged 4 commits into from
Oct 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/jekyll/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,13 @@ def documents
end

def each_site_file
seen_files = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One optimization is to use a Set here. Faster than array for the call to include?.

%w(pages static_files_to_write docs_to_write).each do |type|
send(type).each do |item|
next if seen_files.include?(item)

yield item
seen_files << item
end
end
end
Expand Down
9 changes: 9 additions & 0 deletions test/test_site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -749,5 +749,14 @@ def convert(*_args)

assert_includes site.static_files.map(&:relative_path), "_methods/extensionless_static_file"
end

should "not be revisited in `Site#each_site_file`" do
site = fixture_site("collections" => { "methods" => { "output" => true } })
site.read

visited_files = []
site.each_site_file { |file| visited_files << file }
assert_equal visited_files.count, visited_files.uniq.count
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also confirmed that this failed with the old implementation

end
end
end