Skip to content

Commit d02cb75

Browse files
committed
Fix generates problems.
1 parent 47dc87a commit d02cb75

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

internal/fingerprint/glob.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package fingerprint
33
import (
44
"os"
55
"sort"
6+
"strings"
67

78
"github.com/go-task/task/v3/internal/execext"
89
"github.com/go-task/task/v3/internal/filepathext"
@@ -25,6 +26,7 @@ func Globs(dir string, globs []*ast.Glob) ([]string, error) {
2526

2627
func glob(dir string, g string) ([]string, error) {
2728
g = filepathext.SmartJoin(dir, g)
29+
g = strings.Replace(g, " ", `\ `, -1)
2830

2931
fs, err := execext.ExpandFields(g)
3032
if err != nil {

internal/fingerprint/sources_timestamp.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,21 @@ func (checker *TimestampChecker) IsUpToDate(t *ast.Task) (bool, error) {
3232
if err != nil {
3333
return false, nil
3434
}
35-
generates, err := Globs(t.Dir, t.Generates)
36-
if err != nil {
35+
generates := []string{}
36+
for _, g := range t.Generates {
37+
if g.Negate {
38+
continue // 'excludes' not considered for generates.
39+
}
40+
files, err := glob(t.Dir, g.Glob)
41+
if os.IsNotExist(err) || len(files) == 0 {
42+
return false, nil
43+
}
44+
if err != nil {
45+
return false, err
46+
}
47+
generates = append(generates, files...)
48+
}
49+
if len(generates) == 0 {
3750
return false, nil
3851
}
3952

0 commit comments

Comments
 (0)