Add checksum for "generates" (proof of concept)
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
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
@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
Still working fine for me after the latest changes. 👍🏻
I'm looking forward to this feature.
Another case that proves we need fingerprinting with Generates.
#1945
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.