Add inherit_outdated attribute to task dependencies #2677
+258
−28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relates to #669
Alternative Approach to #2677
Summary
This PR adds a new
inherit_outdatedattribute to task dependencies in the Taskfile. When set totrueon a dependency, the parent task will be considered "not up-to-date" if that dependency (or any of its transitive dependencies marked withinherit_outdated) is not up-to-date.Motivation
Currently,
task --status my-taskonly checks ifmy-taskitself is up-to-date, ignoring whether its dependencies are up-to-date. This makes it difficult to express tasks where the parent should be considered outdated when specific critical dependencies are outdated.For software development cases, it's common to model this relationship via "generates" and "sources". This is how it was done canonically in
Makefilesas well. However, "go-task" intends more general purpose, and has found purchase in many devops scenarios. In many non-development scenarios, tasks don't generate sources naturally so there's no native way to express this relationship. As a workaround, tasks can be engineered to generate "artificial files" like "stamp" files, but this is tedious and awkward and has holes.This approach provides first-class, declarative control at the Taskfile level, allowing task authors to specify which dependencies should propagate their outdated status.
Comparison to Flag-Based Approach
This is an alternative to adding a
--include-depsCLI flag. Key differences:Flag-based approach (--include-deps):
Attribute-based approach (inherit_outdated):
Changes
Usage
Define dependencies with
inherit_outdated: truein your Taskfile:Then check status normally:
Use Cases
This is particularly useful when:
Example: Multi-level Inheritance
With this setup,
task --status deploywill check:But will NOT check lint or test tasks.
Implementation Details
Testing
Backwards Compatibility
This change is fully backwards compatible: