1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00

Small adjustments and CHANGELOG for #359

This commit is contained in:
Andrey Nering
2021-07-31 20:29:59 -03:00
parent 046a97d1e5
commit 8aa983257d
3 changed files with 24 additions and 6 deletions

View File

@@ -1,5 +1,13 @@
# Changelog # Changelog
## Unreleased
- Add `run:` setting to control if tasks should run multiple times or not.
Available options are `always` (the default), `when_changed` (if a variable
modified the task) and `once` (run only once no matter what).
This is a long time requested feature. Enjoy!
([#53](https://github.com/go-task/task/issues/53), [#359](https://github.com/go-task/task/pull/359)).
## v3.6.0 - 2021-07-10 ## v3.6.0 - 2021-07-10
- Allow using both `sources:` and `status:` in the same task - Allow using both `sources:` and `status:` in the same task

View File

@@ -455,12 +455,13 @@ tasks:
### Limiting when tasks run ### Limiting when tasks run
If a task executed by multiple `cmds` or multiple `deps` you can limit If a task executed by multiple `cmds` or multiple `deps` you can control
how many times it is executed using `run`. `run` can also be set at the root when it is executed using `run`. `run` can also be set at the root
of the Taskfile to change the behavior of all the tasks unless explicitly of the Taskfile to change the behavior of all the tasks unless explicitly
overridden overridden.
Supported values for `run`:
Supported values for `run`
* `always` (default) always attempt to invoke the task regardless of the * `always` (default) always attempt to invoke the task regardless of the
number of previous executions number of previous executions
* `once` only invoke this task once regardless of the number of references * `once` only invoke this task once regardless of the number of references
@@ -468,7 +469,8 @@ Supported values for `run`
passed into the task passed into the task
```yaml ```yaml
version: '3.7' version: '3'
tasks: tasks:
default: default:
cmds: cmds:

10
task.go
View File

@@ -151,6 +151,9 @@ func (e *Executor) Setup() error {
if v == 2.0 { if v == 2.0 {
v = 2.6 v = 2.6
} }
if v == 3.0 {
v = 3.7
}
if v > 3.7 { if v > 3.7 {
return fmt.Errorf(`task: Taskfile versions greater than v3.7 not implemented in the version of Task`) return fmt.Errorf(`task: Taskfile versions greater than v3.7 not implemented in the version of Task`)
@@ -480,14 +483,19 @@ func (e *Executor) startExecution(ctx context.Context, t *taskfile.Task, execute
e.executionHashesMutex.Lock() e.executionHashesMutex.Lock()
otherExecutionCtx, ok := e.executionHashes[h] otherExecutionCtx, ok := e.executionHashes[h]
e.executionHashesMutex.Unlock()
if ok { if ok {
e.executionHashesMutex.Unlock()
e.Logger.VerboseErrf(logger.Magenta, "task: skipping execution of task: %s", h)
<-otherExecutionCtx.Done() <-otherExecutionCtx.Done()
return nil return nil
} }
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
defer cancel() defer cancel()
e.executionHashes[h] = ctx e.executionHashes[h] = ctx
e.executionHashesMutex.Unlock()
return execute(ctx) return execute(ctx)
} }