mirror of
https://github.com/go-task/task.git
synced 2025-03-03 14:52:13 +02:00
24 lines
454 B
Go
24 lines
454 B
Go
|
package hash
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"github.com/go-task/task/v3/taskfile"
|
||
|
"github.com/mitchellh/hashstructure/v2"
|
||
|
)
|
||
|
|
||
|
type HashFunc func(*taskfile.Task) (string, error)
|
||
|
|
||
|
func Empty(*taskfile.Task) (string, error) {
|
||
|
return "", nil
|
||
|
}
|
||
|
|
||
|
func Name(t *taskfile.Task) (string, error) {
|
||
|
return t.Task, nil
|
||
|
}
|
||
|
|
||
|
func Hash(t *taskfile.Task) (string, error) {
|
||
|
h, err := hashstructure.Hash(t, hashstructure.FormatV2, nil)
|
||
|
return fmt.Sprintf("%s:%d", t.Task, h), err
|
||
|
}
|