fix: avoid clobbering sh: vars when resolving global Ref values by JonZeolla · Pull Request #2721 · go-task/task

and others added 3 commits

March 7, 2026 18:24
…bbering sh: vars

The ReplaceVars call added in go-task#2632 re-processes all TaskfileVars after
they've been resolved by rangeFunc. For sh: variables, this overwrites the
already-resolved Value with a new Var that has the original Sh string but
nil Value, causing dynamic variables to resolve to empty strings when the
Taskfile has includes.

Fix by only resolving variables that actually have Ref values set, leaving
already-resolved sh: variables untouched.

Fixes go-task#2720

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Temporarily reverting the compiler.go fix while keeping the test to
demonstrate TDD — CI should fail on TestShVarWithIncludes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Re-applying the fix now that CI has demonstrated the test catches the
regression. CI should pass on this commit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

JonZeolla added a commit to JonZeolla/task that referenced this pull request

Mar 9, 2026
Add TestShVarWithIncludes to ensure sh: dynamic variables are correctly
resolved when a Taskfile also has includes. This guards against
regressions like the one fixed in v3.49.1 (go-task#2720, go-task#2721).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>