1
0
mirror of https://github.com/go-task/task.git synced 2025-04-09 07:13:59 +02:00

fix: status and sources

This commit is contained in:
Pete Davison 2023-03-07 00:30:24 +00:00
parent 6e346de9fb
commit f1506ee500
2 changed files with 30 additions and 15 deletions

View File

@ -4,7 +4,7 @@
- Fixed bug where `.task/checksum` file was sometimes not being created when
task also declares a `status:`
([#840](https://github.com/go-task/task/issues/840), [#1035](https://github.com/go-task/task/pull/1035) by @harelwa).
([#840](https://github.com/go-task/task/issues/840), [#1035](https://github.com/go-task/task/pull/1035) by @harelwa, [#1037](https://github.com/go-task/task/pull/1037) by @pd93).
- Fixed deadlock issue when using `run: once`
([#715](https://github.com/go-task/task/issues/715), [#1025](https://github.com/go-task/task/pull/1025) by @theunrepentantgeek).

View File

@ -29,36 +29,51 @@ func (e *Executor) Status(ctx context.Context, calls ...taskfile.Call) error {
}
func (e *Executor) isTaskUpToDate(ctx context.Context, t *taskfile.Task) (bool, error) {
isUpToDateStatus := true
isUpToDateChecker := true
var statusUpToDate bool
var sourcesUpToDate bool
var err error
if len(t.Status) > 0 {
isUpToDate, err := e.isTaskUpToDateStatus(ctx, t)
statusIsSet := len(t.Status) != 0
sourcesIsSet := len(t.Sources) != 0
// If status is set, check if it is up-to-date
if statusIsSet {
statusUpToDate, err = e.isTaskUpToDateStatus(ctx, t)
if err != nil {
return false, err
}
if !isUpToDate {
isUpToDateStatus = false
}
}
if len(t.Sources) > 0 {
// If sources is set, check if they are up-to-date
if sourcesIsSet {
checker, err := e.getStatusChecker(t)
if err != nil {
return false, err
}
isUpToDate, err := checker.IsUpToDate()
sourcesUpToDate, err = checker.IsUpToDate()
if err != nil {
return false, err
}
if !isUpToDate {
isUpToDateChecker = false
}
}
isUpToDate := isUpToDateStatus && isUpToDateChecker
// If both status and sources are set, the task is up-to-date if both are up-to-date
if statusIsSet && sourcesIsSet {
return statusUpToDate && sourcesUpToDate, nil
}
return isUpToDate, nil
// If only status is set, the task is up-to-date if the status is up-to-date
if statusIsSet {
return statusUpToDate, nil
}
// If only sources is set, the task is up-to-date if the sources are up-to-date
if sourcesIsSet {
return sourcesUpToDate, nil
}
// If no status or sources are set, the task should always run
// i.e. it is never considered "up-to-date"
return false, nil
}
func (e *Executor) statusOnError(t *taskfile.Task) error {