From d02cb75d6bc908d675a56ed3e69f1acd58079e03 Mon Sep 17 00:00:00 2001 From: Timothy Rule <34501912+trulede@users.noreply.github.com> Date: Sat, 5 Jul 2025 16:23:57 +0200 Subject: [PATCH 1/2] Fix generates problems. --- internal/fingerprint/glob.go | 2 ++ internal/fingerprint/sources_timestamp.go | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/internal/fingerprint/glob.go b/internal/fingerprint/glob.go index bf12afdd12..86fa01c2e5 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.Replace(g, " ", `\ `, -1) 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 } From e5b31c18451ed62d9d2a62981a69b0a9670e3327 Mon Sep 17 00:00:00 2001 From: Timothy Rule <34501912+trulede@users.noreply.github.com> Date: Sat, 5 Jul 2025 16:49:57 +0200 Subject: [PATCH 2/2] Update glob.go for linter suggestion. --- internal/fingerprint/glob.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/fingerprint/glob.go b/internal/fingerprint/glob.go index 86fa01c2e5..525a12e05f 100644 --- a/internal/fingerprint/glob.go +++ b/internal/fingerprint/glob.go @@ -26,7 +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.Replace(g, " ", `\ `, -1) + g = strings.ReplaceAll(g, " ", `\ `) fs, err := execext.ExpandFields(g) if err != nil {