-
-
Notifications
You must be signed in to change notification settings - Fork 617
/
status.go
54 lines (47 loc) · 1.17 KB
/
status.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package task
import (
"context"
"fmt"
"github.com/go-task/task/v3/internal/fingerprint"
"github.com/go-task/task/v3/taskfile/ast"
)
// Status returns an error if any the of given tasks is not up-to-date
func (e *Executor) Status(ctx context.Context, calls ...*ast.Call) error {
for _, call := range calls {
// Compile the task
t, err := e.CompiledTask(call)
if err != nil {
return err
}
// Get the fingerprinting method to use
method := e.Taskfile.Method
if t.Method != "" {
method = t.Method
}
// Check if the task is up-to-date
isUpToDate, err := fingerprint.IsTaskUpToDate(ctx, t,
fingerprint.WithMethod(method),
fingerprint.WithTempDir(e.TempDir.Fingerprint),
fingerprint.WithDry(e.Dry),
fingerprint.WithLogger(e.Logger),
)
if err != nil {
return err
}
if !isUpToDate {
return fmt.Errorf(`task: Task "%s" is not up-to-date`, t.Name())
}
}
return nil
}
func (e *Executor) statusOnError(t *ast.Task) error {
method := t.Method
if method == "" {
method = e.Taskfile.Method
}
checker, err := fingerprint.NewSourcesChecker(method, e.TempDir.Fingerprint, e.Dry)
if err != nil {
return err
}
return checker.OnError(t)
}