Skip to content

Commit

Permalink
Process metadata for all dependencies
Browse files Browse the repository at this point in the history
When adding a dependency, also add the dependency to the metadata hash.

Addresses part 1 of #3591. Prior to this fix, the regnerator only paid attention the mtime of the first dependency it checked, so for posts/pages with N multiple dependencies (i.e., every layout file used to render them), it continues to regenerate the post/page approximately N times, at which point it's seen all of the dependencies.
  • Loading branch information
nickburlett committed Mar 22, 2015
1 parent e770a08 commit d4b8f0d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/jekyll/regenerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ def modified?(path)
def add_dependency(path, dependency)
return if (metadata[path].nil? || @disabled)

metadata[path]["deps"] << dependency unless metadata[path]["deps"].include? dependency
if !metadata[path]["deps"].include? dependency
metadata[path]["deps"] << dependency
add(dependency) unless metadata.include?(dependency)
end
regenerate? dependency
end

Expand Down
14 changes: 14 additions & 0 deletions test/test_regenerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,20 @@ class TestRegenerator < JekyllUnitTest
assert @regenerator.modified?(@path)
end

should "not regenerate again if multiple dependencies" do
multi_deps = @regenerator.metadata.select {|k,v| v['deps'].length > 2}
multi_dep_path = multi_deps.keys.first

assert @regenerator.metadata[multi_dep_path]["deps"].length > 2

assert @regenerator.modified?(multi_dep_path)

@site.process
@regenerator.clear_cache

refute @regenerator.modified?(multi_dep_path)
end

should "regenerate everything if metadata is disabled" do
@site.config["full_rebuild"] = true
@regenerator.clear
Expand Down

0 comments on commit d4b8f0d

Please sign in to comment.