mirror of
https://github.com/go-task/task.git
synced 2025-01-22 05:10:17 +02:00
fix: checksum variable in status is incorrect (#1080)
* fix: checksum variable in status is incorrect * chore: changelog
This commit is contained in:
parent
34f15a4976
commit
738ffde962
@ -14,6 +14,7 @@
|
||||
(`{{splitArgs "foo bar 'foo bar baz'"}}`) to ensure string is splitted as
|
||||
arguments not whitespaces
|
||||
([#1040](https://github.com/go-task/task/issues/1040), [#1059](https://github.com/go-task/task/pull/1059) by @dhanusaputra).
|
||||
- Fix the value of `{{.CHECKSUM}}` variable in status ([#1076](https://github.com/go-task/task/issues/1076), [#1080](https://github.com/go-task/task/pull/1080) by @pd93).
|
||||
|
||||
## v3.22.0 - 2023-03-10
|
||||
|
||||
|
@ -37,12 +37,7 @@ func (checker *ChecksumChecker) IsUpToDate(t *taskfile.Task) (bool, error) {
|
||||
data, _ := os.ReadFile(checksumFile)
|
||||
oldMd5 := strings.TrimSpace(string(data))
|
||||
|
||||
sources, err := globs(t.Dir, t.Sources)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
newMd5, err := checker.checksum(sources...)
|
||||
newMd5, err := checker.checksum(t)
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
@ -74,7 +69,7 @@ func (checker *ChecksumChecker) IsUpToDate(t *taskfile.Task) (bool, error) {
|
||||
}
|
||||
|
||||
func (checker *ChecksumChecker) Value(t *taskfile.Task) (interface{}, error) {
|
||||
return checker.checksum()
|
||||
return checker.checksum(t)
|
||||
}
|
||||
|
||||
func (checker *ChecksumChecker) OnError(t *taskfile.Task) error {
|
||||
@ -88,10 +83,14 @@ func (*ChecksumChecker) Kind() string {
|
||||
return "checksum"
|
||||
}
|
||||
|
||||
func (c *ChecksumChecker) checksum(files ...string) (string, error) {
|
||||
h := md5.New()
|
||||
func (c *ChecksumChecker) checksum(t *taskfile.Task) (string, error) {
|
||||
sources, err := globs(t.Dir, t.Sources)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
for _, f := range files {
|
||||
h := md5.New()
|
||||
for _, f := range sources {
|
||||
// also sum the filename, so checksum changes for renaming a file
|
||||
if _, err := io.Copy(h, strings.NewReader(filepath.Base(f))); err != nil {
|
||||
return "", err
|
||||
|
@ -691,7 +691,7 @@ func TestStatusVariables(t *testing.T) {
|
||||
assert.NoError(t, e.Setup())
|
||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "build"}))
|
||||
|
||||
assert.Contains(t, buff.String(), "d41d8cd98f00b204e9800998ecf8427e")
|
||||
assert.Contains(t, buff.String(), "a41e7948dcd321db412ce61d3d5c9864")
|
||||
|
||||
inf, err := os.Stat(filepathext.SmartJoin(dir, "source.txt"))
|
||||
assert.NoError(t, err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user