1
0
mirror of https://github.com/go-task/task.git synced 2025-11-29 22:48:03 +02:00

Only run task once for #53

This commit is contained in:
Ross Hammermeister
2020-08-17 13:25:17 -06:00
committed by Andrey Nering
parent a7b59e5b12
commit 97c85e39c3
12 changed files with 173 additions and 0 deletions

28
hash.go Normal file
View File

@@ -0,0 +1,28 @@
package task
import (
"fmt"
"github.com/go-task/task/v3/internal/hash"
"github.com/go-task/task/v3/taskfile"
)
func (e *Executor) GetHash(t *taskfile.Task) (string, error) {
r := t.Run
if r == "" {
r = e.Taskfile.Run
}
var h hash.HashFunc
switch r {
case "always":
h = hash.Empty
case "once":
h = hash.Name
case "when_changed":
h = hash.Hash
default:
return "", fmt.Errorf(`task: invalid run "%s"`, r)
}
return h(t)
}