diff --git a/internal/fingerprint/glob.go b/internal/fingerprint/glob.go index bf12afdd12..525a12e05f 100644 --- a/internal/fingerprint/glob.go +++ b/internal/fingerprint/glob.go @@ -3,6 +3,7 @@ package fingerprint import ( "os" "sort" + "strings" "github.com/go-task/task/v3/internal/execext" "github.com/go-task/task/v3/internal/filepathext" @@ -25,6 +26,7 @@ func Globs(dir string, globs []*ast.Glob) ([]string, error) { func glob(dir string, g string) ([]string, error) { g = filepathext.SmartJoin(dir, g) + g = strings.ReplaceAll(g, " ", `\ `) fs, err := execext.ExpandFields(g) if err != nil { diff --git a/internal/fingerprint/sources_timestamp.go b/internal/fingerprint/sources_timestamp.go index b1a6f299d5..2127aba00c 100644 --- a/internal/fingerprint/sources_timestamp.go +++ b/internal/fingerprint/sources_timestamp.go @@ -32,8 +32,21 @@ func (checker *TimestampChecker) IsUpToDate(t *ast.Task) (bool, error) { if err != nil { return false, nil } - generates, err := Globs(t.Dir, t.Generates) - if err != nil { + generates := []string{} + for _, g := range t.Generates { + if g.Negate { + continue // 'excludes' not considered for generates. + } + files, err := glob(t.Dir, g.Glob) + if os.IsNotExist(err) || len(files) == 0 { + return false, nil + } + if err != nil { + return false, err + } + generates = append(generates, files...) + } + if len(generates) == 0 { return false, nil }