fix: globals vars are available in vars at root level by vmaerten · Pull Request #2403 · go-task/task

@vmaerten

@vmaerten marked this pull request as ready for review

August 25, 2025 19:02

@vmaerten vmaerten deleted the fix/globals-vars-available branch

December 12, 2025 20:20

vmaerten added a commit that referenced this pull request

Dec 12, 2025

vmaerten added a commit that referenced this pull request

Dec 18, 2025
When using `task FOO=bar` with a Taskfile containing
`FOO: '{{.FOO | default "foo"}}'`, the CLI value was being
overwritten by the Taskfile default.

The ReverseMerge function was incorrectly allowing Taskfile
variables to overwrite CLI globals. Now it skips variables
that already exist in the CLI globals, ensuring user-provided
values take priority while still making CLI globals available
for templating.

Fixes regression introduced in #2403.

vmaerten added a commit that referenced this pull request

Dec 18, 2025
When using `task FOO=bar` with a Taskfile containing
`FOO: '{{.FOO | default "foo"}}'`, the CLI value was being
overwritten by the Taskfile default.

Split the variable merging into two steps:
1. Merge CLI variables (FOO=bar) first so they override Taskfile vars
2. ReverseMerge special variables (CLI_ARGS, CLI_FORCE, etc.) so
   they're available for templating in Taskfile vars

Fixes regression introduced in #2403.

Co-authored-by: Timothy Rule <timothy.rule@gmail.com>

andreynering pushed a commit that referenced this pull request

Dec 18, 2025
When using `task FOO=bar` with a Taskfile containing
`FOO: '{{.FOO | default "foo"}}'`, the CLI value was being
overwritten by the Taskfile default.

Split the variable merging into two steps:
1. Merge CLI variables (FOO=bar) first so they override Taskfile vars
2. ReverseMerge special variables (CLI_ARGS, CLI_FORCE, etc.) so
   they're available for templating in Taskfile vars

Fixes regression introduced in #2403.

Co-authored-by: Timothy Rule <timothy.rule@gmail.com>

Copilot AI pushed a commit to libor-m/task that referenced this pull request

Mar 27, 2026
Co-authored-by: libor-m <1497769+libor-m@users.noreply.github.com>

Copilot AI pushed a commit to libor-m/task that referenced this pull request

Mar 27, 2026
Co-authored-by: libor-m <1497769+libor-m@users.noreply.github.com>

Copilot AI pushed a commit to libor-m/task that referenced this pull request

Mar 27, 2026
…sk#2589)

When using `task FOO=bar` with a Taskfile containing
`FOO: '{{.FOO | default "foo"}}'`, the CLI value was being
overwritten by the Taskfile default.

Split the variable merging into two steps:
1. Merge CLI variables (FOO=bar) first so they override Taskfile vars
2. ReverseMerge special variables (CLI_ARGS, CLI_FORCE, etc.) so
   they're available for templating in Taskfile vars

Fixes regression introduced in go-task#2403.

Co-authored-by: Timothy Rule <timothy.rule@gmail.com>
Co-authored-by: libor-m <1497769+libor-m@users.noreply.github.com>