Skip to content

refactor: centralize fingerprint method resolution in a Fingerprinter#2924

Open
vmaerten wants to merge 1 commit into
mainfrom
refactor/fingerprinter
Open

refactor: centralize fingerprint method resolution in a Fingerprinter#2924
vmaerten wants to merge 1 commit into
mainfrom
refactor/fingerprinter

Conversation

@vmaerten

@vmaerten vmaerten commented Jul 19, 2026

Copy link
Copy Markdown
Member

Summary

IsTaskUpToDate is duplicated in multiple files. I've extracted in a Finderprinter struct.

It also fix an issue.

version: '3'
method: timestamp        # défini au niveau du Taskfile

tasks:
  build:
    sources: [source.txt]
    cmds:
      - echo "TIMESTAMP = {{.TIMESTAMP}}"

Before (main) timestamp would be empty
Now, it's fixed

@vmaerten
vmaerten marked this pull request as ready for review July 19, 2026 19:08
The decision "is this task up to date?" was spread over five call sites:
the method-selection idiom (task method falling back to the Taskfile
method) was copied verbatim in RunTask, Status and ToEditorOutput, and
the sources checker was constructed separately in statusOnError and in
compiledTask for the CHECKSUM/TIMESTAMP variable injection.

Introduce a Fingerprinter in internal/fingerprint that owns method
resolution and checker construction behind a small interface (UpToDate,
OnError, Kind, SourceValue), and route all five call sites through it.
It is built on the fly from the Executor's current state because
exported fields like Dry may legitimately be mutated between runs.

This also fixes the fingerprint variable ignoring a method set at the
Taskfile level: compiledTask picked the checker from the task's own
method only, so with a Taskfile-level "method: timestamp" the injected
variable was computed by the checksum checker while the up-to-date
check used timestamp. The variable now follows the same resolution as
the up-to-date check, and is no longer injected when the effective
method is "none".
@vmaerten
vmaerten force-pushed the refactor/fingerprinter branch from 2dcf108 to 95ec19f Compare July 19, 2026 19:09
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.

1 participant