Skip to content

fix: report no timestamp when a task's sources match no file - #2960

Open
vmaerten wants to merge 2 commits into
mainfrom
fix/timestamp-empty-sources
Open

fix: report no timestamp when a task's sources match no file#2960
vmaerten wants to merge 2 commits into
mainfrom
fix/timestamp-empty-sources

Conversation

@vmaerten

@vmaerten vmaerten commented Aug 9, 2026

Copy link
Copy Markdown
Member

Summary

TimestampChecker.Value returns a sentinel when a task's sources match no file: originally the string "0", then time.Unix(0, 0) once the value became a time.Time exposed to templates. Rendered, that sentinel reads as a genuine date — 1970-01-01 01:00:00 +0100 CET, with a zone that depends on the machine — so a command interpolating {{.TIMESTAMP}} receives a plausible, meaningless, multi-word value instead of nothing. It now returns an empty string, like NoneChecker already does for a checker with nothing to report.

This is user-visible: a task with method: timestamp whose glob matches nothing used to print 1970-01-01 01:00:00 +0100 CET and now prints nothing.

Test plan

  • TestTimestampCheckerValue covers both branches of the checker: a real modification time when a source matches, and no value when the glob matches nothing.
  • Manually verified with binaries built from main and from this branch, on a Taskfile with method: timestamp and sources: ['./gen/**/*.go'] in a directory with no gen/: main prints ts=[1970-01-01 01:00:00 +0100 CET], this branch prints ts=[].

vmaerten added a commit that referenced this pull request Aug 9, 2026
vmaerten added a commit that referenced this pull request Aug 9, 2026
@vmaerten
vmaerten force-pushed the fix/timestamp-empty-sources branch from c9ac146 to 7551ba0 Compare August 9, 2026 20:58
Base automatically changed from refactor/fingerprinter to main August 10, 2026 14:12
TimestampChecker.Value returned a sentinel for "no source found": first
the string "0", then time.Unix(0, 0) once the value became a time.Time
exposed to templates. Rendered, that sentinel reads as a genuine date,
1970-01-01 01:00:00 +0100 CET, whose zone depends on the machine — so a
command interpolating {{.TIMESTAMP}} gets a plausible but meaningless
multi-word value instead of nothing.

Return an empty string, like NoneChecker already does for a checker with
nothing to report.
@vmaerten
vmaerten force-pushed the fix/timestamp-empty-sources branch from 7551ba0 to 0c6c941 Compare August 10, 2026 14:12
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