1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-11-30 06:59:04 +01:00

more accurate file change detection

This commit is contained in:
Oliver Steele 2017-07-26 12:47:31 -04:00
parent b789096b3a
commit 1fb409b4a8

View File

@ -3,6 +3,7 @@ package site
import (
"fmt"
"os"
"path/filepath"
"strings"
"time"
@ -129,7 +130,7 @@ loop:
switch {
case s.config.IsConfigPath(path):
// break
case s.Exclude(path):
case !s.fileAffectsBuild(path):
continue loop
case seen[path]:
continue loop
@ -140,6 +141,25 @@ loop:
return result
}
// Returns true if the file or a parent directory is excluded.
// Cf. Site.Exclude.
func (s *Site) fileAffectsBuild(rel string) bool {
for rel != "" {
switch {
case rel == ".":
return true
case utils.MatchList(s.config.Include, rel):
return true
case utils.MatchList(s.config.Exclude, rel):
return false
case strings.HasPrefix(rel, "."):
return false
}
rel = filepath.Dir(rel)
}
return true
}
// returns true if changes to the site-relative paths invalidate doc
func (s *Site) invalidatesDoc(paths map[string]bool, d pages.Document) bool {
rel := utils.MustRel(s.SourceDir(), d.SourcePath())