mirror of
https://github.com/go-task/task.git
synced 2025-02-09 13:47:06 +02:00
Make "checksum" the default method in v3
This commit is contained in:
parent
8020284b12
commit
78595fba0b
@ -23,6 +23,10 @@ type Checksum struct {
|
||||
|
||||
// IsUpToDate implements the Checker interface
|
||||
func (c *Checksum) IsUpToDate() (bool, error) {
|
||||
if len(c.Sources) == 0 {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
checksumFile := c.checksumFilePath()
|
||||
|
||||
data, _ := ioutil.ReadFile(checksumFile)
|
||||
|
@ -55,7 +55,7 @@ func (e *Executor) getStatusChecker(t *taskfile.Task) (status.Checker, error) {
|
||||
method = e.Taskfile.Method
|
||||
}
|
||||
switch method {
|
||||
case "", "timestamp":
|
||||
case "timestamp":
|
||||
return &status.Timestamp{
|
||||
Dir: t.Dir,
|
||||
Sources: t.Sources,
|
||||
|
8
task.go
8
task.go
@ -169,6 +169,14 @@ func (e *Executor) Setup() error {
|
||||
return fmt.Errorf(`task: output option "%s" not recognized`, e.Taskfile.Output)
|
||||
}
|
||||
|
||||
if e.Taskfile.Method == "" {
|
||||
if v >= 3 {
|
||||
e.Taskfile.Method = "checksum"
|
||||
} else {
|
||||
e.Taskfile.Method = "timestamp"
|
||||
}
|
||||
}
|
||||
|
||||
if v <= 2.1 {
|
||||
err := errors.New(`task: Taskfile option "ignore_error" is only available starting on Taskfile version v2.1`)
|
||||
|
||||
|
@ -630,7 +630,7 @@ func TestWhenDirAttributeItCreatesMissingAndRunsInThatDir(t *testing.T) {
|
||||
}
|
||||
|
||||
// Ensure that the directory to be created doesn't actually exist.
|
||||
_ = os.Remove(toBeCreated)
|
||||
_ = os.RemoveAll(toBeCreated)
|
||||
if _, err := os.Stat(toBeCreated); err == nil {
|
||||
t.Errorf("Directory should not exist: %v", err)
|
||||
}
|
||||
@ -641,7 +641,7 @@ func TestWhenDirAttributeItCreatesMissingAndRunsInThatDir(t *testing.T) {
|
||||
assert.Equal(t, expected, got, "Mismatch in the working directory")
|
||||
|
||||
// Clean-up after ourselves only if no error.
|
||||
_ = os.Remove(toBeCreated)
|
||||
_ = os.RemoveAll(toBeCreated)
|
||||
}
|
||||
|
||||
func TestDisplaysErrorOnUnsupportedVersion(t *testing.T) {
|
||||
|
4
testdata/generates/Taskfile.yml
vendored
4
testdata/generates/Taskfile.yml
vendored
@ -8,6 +8,7 @@ tasks:
|
||||
dir: sub
|
||||
cmds:
|
||||
- cat src.txt > '{{.BUILD_DIR}}/abs.txt'
|
||||
method: timestamp
|
||||
sources:
|
||||
- src.txt
|
||||
generates:
|
||||
@ -20,6 +21,7 @@ tasks:
|
||||
dir: sub
|
||||
cmds:
|
||||
- cat src.txt > '../rel.txt'
|
||||
method: timestamp
|
||||
sources:
|
||||
- src.txt
|
||||
generates:
|
||||
@ -30,6 +32,7 @@ tasks:
|
||||
cmds:
|
||||
- mkdir -p sub
|
||||
- echo "hello world" > sub/src.txt
|
||||
method: timestamp
|
||||
status:
|
||||
- test -f sub/src.txt
|
||||
|
||||
@ -38,6 +41,7 @@ tasks:
|
||||
deps: [sub/src.txt]
|
||||
cmds:
|
||||
- cat sub/src.txt > 'my text file.txt'
|
||||
method: timestamp
|
||||
sources:
|
||||
- sub/src.txt
|
||||
generates:
|
||||
|
Loading…
x
Reference in New Issue
Block a user