Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7b59e5
commit 97c85e3
Showing
12 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
version: '3' | ||
run: when_changed | ||
|
||
tasks: | ||
generate-hash: | ||
- rm -f hash.txt | ||
- task: input-content | ||
vars: { CONTENT: '1' } | ||
- task: input-content | ||
vars: { CONTENT: '2' } | ||
- task: input-content | ||
vars: { CONTENT: '2' } | ||
|
||
input-content: | ||
deps: | ||
- task: create-output | ||
vars: { CONTENT: '1' } | ||
cmds: | ||
- echo {{.CONTENT}} >> hash.txt | ||
|
||
create-output: | ||
run: once | ||
cmds: | ||
- echo starting {{.CONTENT}} >> hash.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters