hash.go 437 B

12345678910111213141516171819202122232425
  1. package task
  2. import (
  3. "cmp"
  4. "fmt"
  5. "github.com/go-task/task/v3/internal/hash"
  6. "github.com/go-task/task/v3/taskfile/ast"
  7. )
  8. func (e *Executor) GetHash(t *ast.Task) (string, error) {
  9. r := cmp.Or(t.Run, e.Taskfile.Run)
  10. var h hash.HashFunc
  11. switch r {
  12. case "always":
  13. h = hash.Empty
  14. case "once":
  15. h = hash.Name
  16. case "when_changed":
  17. h = hash.Hash
  18. default:
  19. return "", fmt.Errorf(`task: invalid run "%s"`, r)
  20. }
  21. return h(t)
  22. }