mirror of
https://github.com/go-task/task.git
synced 2024-12-14 10:52:43 +02:00
3aaa3223a0
* fix: run once in shared dependencies * feat: add test
26 lines
495 B
Go
26 lines
495 B
Go
package task
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/go-task/task/v3/internal/hash"
|
|
"github.com/go-task/task/v3/internal/slicesext"
|
|
"github.com/go-task/task/v3/taskfile/ast"
|
|
)
|
|
|
|
func (e *Executor) GetHash(t *ast.Task) (string, error) {
|
|
r := slicesext.FirstNonZero(t.Run, 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)
|
|
}
|