MCPcopy
hub / github.com/go-task/task / IsTaskUpToDate

Function IsTaskUpToDate

internal/fingerprint/task.go:58–132  ·  view source on GitHub ↗
(
	ctx context.Context,
	t *ast.Task,
	opts ...CheckerOption,
)

Source from the content-addressed store, hash-verified

56}
57
58func IsTaskUpToDate(
59 ctx context.Context,
60 t *ast.Task,
61 opts ...CheckerOption,
62) (bool, error) {
63 var statusUpToDate bool
64 var sourcesUpToDate bool
65 var err error
66
67 // Default config
68 config := &CheckerConfig{
69 method: "none",
70 tempDir: "",
71 dry: false,
72 logger: nil,
73 statusChecker: nil,
74 sourcesChecker: nil,
75 }
76
77 // Apply functional options
78 for _, opt := range opts {
79 opt(config)
80 }
81
82 // If no status checker was given, set up the default one
83 if config.statusChecker == nil {
84 config.statusChecker = NewStatusChecker(config.logger)
85 }
86
87 // If no sources checker was given, set up the default one
88 if config.sourcesChecker == nil {
89 config.sourcesChecker, err = NewSourcesChecker(config.method, config.tempDir, config.dry)
90 if err != nil {
91 return false, err
92 }
93 }
94
95 statusIsSet := len(t.Status) != 0
96 sourcesIsSet := len(t.Sources) != 0
97
98 // If status is set, check if it is up-to-date
99 if statusIsSet {
100 statusUpToDate, err = config.statusChecker.IsUpToDate(ctx, t)
101 if err != nil {
102 return false, err
103 }
104 }
105
106 // If sources is set, check if they are up-to-date
107 if sourcesIsSet {
108 sourcesUpToDate, err = config.sourcesChecker.IsUpToDate(t)
109 if err != nil {
110 return false, err
111 }
112 }
113
114 // If both status and sources are set, the task is up-to-date if both are up-to-date
115 if statusIsSet && sourcesIsSet {

Callers 4

ToEditorOutputMethod · 0.92
StatusMethod · 0.92
RunTaskMethod · 0.92
TestIsTaskUpToDateFunction · 0.85

Calls 3

NewStatusCheckerFunction · 0.85
NewSourcesCheckerFunction · 0.85
IsUpToDateMethod · 0.65

Tested by 1

TestIsTaskUpToDateFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…