task icon indicating copy to clipboard operation
task copied to clipboard

Add checksum for "generates" (proof of concept)

Open vanackere opened this issue 1 year ago • 4 comments

Hi,

Here"s a quick proof of concept implementation for properly solving https://github.com/go-task/task/issues/1741

I believe this approach makes sense and I'm willing to work on this (add relevant unit tests, maybe refactor to avoid using a file to keep the original sources hash...) if you think this is worth it !

Best regards,

Vincent

vanackere avatar Sep 19 '24 02:09 vanackere

Hi,

I have a similar issue with the "generates" combined with the "sources": when I remove or edit one output file, the task is not rebuilt and considered "up to date".

I can confirm this PR fixes the issue.

Example task file (with an existing file input.txt):

# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: '3'

tasks:
  build:
    sources:
      - input.txt
    generates:
      - output*.txt
    cmds:
      - echo "test" > output1.txt
      - echo "test" > output2.txt

Result without this PR (Task version: v3.39.0 (h1:Loe6ppP1x38Puv1M2wigp91bH/garCt0vLWkJsiTWNI=):

$ task build
task: [build] echo "test" > output1.txt
task: [build] echo "test" > output2.txt
$ rm output1.txt 
$ task build
task: Task "build" is up to date

Result with this PR:

$ task build
task: [build] echo "test" > output1.txt
task: [build] echo "test" > output2.txt
$ rm output1.txt 
$ task build
task: [build] echo "test" > output1.txt
task: [build] echo "test" > output2.txt
$ task build
task: Task "build" is up to date

flashcode avatar Sep 27 '24 08:09 flashcode

@andreynering / @pd93 / @vmaerten : any feedback on this approach ?

For my particular project this fixes a real issue and I'd like to have it fixed upstream if possible rather than maintaining my own fork for that

vanackere avatar Sep 27 '24 13:09 vanackere

Still working fine for me after the latest changes. 👍🏻

flashcode avatar Sep 27 '24 15:09 flashcode

I'm looking forward to this feature.

ameershira avatar Oct 18 '24 11:10 ameershira

Another case that proves we need fingerprinting with Generates.

#1945

ameershira avatar Dec 18 '24 17:12 ameershira

There are certainly lots of use cases where this could be useful. I see few reasons why you wouldn't want to include the hash of generated files in the evaluation if the task should run.

evilhamsterman avatar Jun 11 '25 23:06 evilhamsterman