Skip to content

Conversation

@vanackere
Copy link

Hi,

Here"s a quick proof of concept implementation for properly solving #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

@flashcode
Copy link

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

@vanackere
Copy link
Author

@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

@flashcode
Copy link

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

@ameergituser
Copy link

I'm looking forward to this feature.

Also add workaround for building with go 1.23
(see vektra/mockery#803)
Follows the same algorithms than for sources, should be much more
understandable & reliable
Avoid writing any state in IsUpToDate, instead return the current source
state and also check after the task is run that the sources checksum has not
been modified
- use the full relative path and not only the base name for hashing
- if we encounter a symlink, hash the link and not the target path
- properly close file on error
@ameergituser
Copy link

Another case that proves we need fingerprinting with Generates.

#1945

@evilhamsterman
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants