feat(taskfile): skip var merge when SCOPED_INCLUDES enabled

When the SCOPED_INCLUDES experiment is enabled, variables from included
Taskfiles are no longer merged globally. They remain in their original
Taskfile within the DAG.

Exception: flatten includes still merge variables globally to allow
sharing common variables across multiple Taskfiles.
This commit is contained in:
Valentin Maerten
2025-12-26 21:02:33 +01:00
parent da927ad5fe
commit 0dbeaaf187
3 changed files with 14 additions and 6 deletions

View File

@@ -57,7 +57,9 @@ func (tfg *TaskfileGraph) Root() (*TaskfileVertex, error) {
return tfg.Vertex(hashes[0])
}
func (tfg *TaskfileGraph) Merge() (*Taskfile, error) {
// Merge merges all included Taskfiles into the root Taskfile.
// If skipVarsMerge is true, variables are not merged (used for scoped includes).
func (tfg *TaskfileGraph) Merge(skipVarsMerge bool) (*Taskfile, error) {
hashes, err := graph.TopologicalSort(tfg.Graph)
if err != nil {
return nil, err
@@ -104,6 +106,7 @@ func (tfg *TaskfileGraph) Merge() (*Taskfile, error) {
if err := vertex.Taskfile.Merge(
includedVertex.Taskfile,
include,
skipVarsMerge,
); err != nil {
return err
}