mirror of
https://github.com/go-task/task.git
synced 2024-12-12 10:45:49 +02:00
29 lines
446 B
Go
29 lines
446 B
Go
|
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)
|
||
|
}
|