Skip to content

Conversation

@vmaerten
Copy link
Member

@vmaerten vmaerten commented Dec 18, 2025

fixes #2588

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.

Copy link
Member

@andreynering andreynering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't personally tested this, but I trust you if you have. Code looks good.

@trulede
Copy link
Contributor

trulede commented Dec 18, 2025

I also tested it for both cases, and a few others, seems good.

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 <[email protected]>
@vmaerten vmaerten force-pushed the fix/cli-vars-priority branch from 2cbb0df to 20f3416 Compare December 18, 2025 20:44
@andreynering andreynering merged commit 9b95e75 into main Dec 18, 2025
13 checks passed
@andreynering andreynering deleted the fix/cli-vars-priority branch December 18, 2025 20:50
andreynering added a commit that referenced this pull request Dec 18, 2025
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.

Variables passed via command line are not processed in task 3.46.1

4 participants