mirror of
https://github.com/go-task/task.git
synced 2026-06-24 21:26:04 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc378cfb92 | ||
|
|
9488a2a744 | ||
|
|
6ece2445ae | ||
|
|
9b95e758f4 |
@@ -1,6 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## v3.46.0 - 2025-12-18
|
## v3.46.2 - 2025-12-18
|
||||||
|
|
||||||
|
- Fixed a regression on previous release that affected variables passed via
|
||||||
|
command line (#2588, #2589 by @vmaerten).
|
||||||
|
|
||||||
|
## v3.46.1 - 2025-12-18
|
||||||
|
|
||||||
### ✨ Features
|
### ✨ Features
|
||||||
|
|
||||||
|
|||||||
@@ -172,18 +172,23 @@ func run() error {
|
|||||||
calls = append(calls, &task.Call{Task: "default"})
|
calls = append(calls, &task.Call{Task: "default"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Merge CLI variables first (e.g. FOO=bar) so they take priority over Taskfile defaults
|
||||||
|
e.Taskfile.Vars.Merge(globals, nil)
|
||||||
|
|
||||||
|
// Then ReverseMerge special variables so they're available for templating
|
||||||
cliArgsPostDashQuoted, err := args.ToQuotedString(cliArgsPostDash)
|
cliArgsPostDashQuoted, err := args.ToQuotedString(cliArgsPostDash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
globals.Set("CLI_ARGS", ast.Var{Value: cliArgsPostDashQuoted})
|
specialVars := ast.NewVars()
|
||||||
globals.Set("CLI_ARGS_LIST", ast.Var{Value: cliArgsPostDash})
|
specialVars.Set("CLI_ARGS", ast.Var{Value: cliArgsPostDashQuoted})
|
||||||
globals.Set("CLI_FORCE", ast.Var{Value: flags.Force || flags.ForceAll})
|
specialVars.Set("CLI_ARGS_LIST", ast.Var{Value: cliArgsPostDash})
|
||||||
globals.Set("CLI_SILENT", ast.Var{Value: flags.Silent})
|
specialVars.Set("CLI_FORCE", ast.Var{Value: flags.Force || flags.ForceAll})
|
||||||
globals.Set("CLI_VERBOSE", ast.Var{Value: flags.Verbose})
|
specialVars.Set("CLI_SILENT", ast.Var{Value: flags.Silent})
|
||||||
globals.Set("CLI_OFFLINE", ast.Var{Value: flags.Offline})
|
specialVars.Set("CLI_VERBOSE", ast.Var{Value: flags.Verbose})
|
||||||
globals.Set("CLI_ASSUME_YES", ast.Var{Value: flags.AssumeYes})
|
specialVars.Set("CLI_OFFLINE", ast.Var{Value: flags.Offline})
|
||||||
e.Taskfile.Vars.ReverseMerge(globals, nil)
|
specialVars.Set("CLI_ASSUME_YES", ast.Var{Value: flags.AssumeYes})
|
||||||
|
e.Taskfile.Vars.ReverseMerge(specialVars, nil)
|
||||||
if !flags.Watch {
|
if !flags.Watch {
|
||||||
e.InterceptInterruptSignals()
|
e.InterceptInterruptSignals()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,6 +263,23 @@ func TestVars(t *testing.T) {
|
|||||||
task.WithSilent(true),
|
task.WithSilent(true),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
NewExecutorTest(t,
|
||||||
|
WithName("cli-var-priority-default"),
|
||||||
|
WithExecutorOptions(
|
||||||
|
task.WithDir("testdata/vars"),
|
||||||
|
task.WithSilent(true),
|
||||||
|
),
|
||||||
|
WithTask("cli-var-priority"),
|
||||||
|
)
|
||||||
|
NewExecutorTest(t,
|
||||||
|
WithName("cli-var-priority-override"),
|
||||||
|
WithExecutorOptions(
|
||||||
|
task.WithDir("testdata/vars"),
|
||||||
|
task.WithSilent(true),
|
||||||
|
),
|
||||||
|
WithTask("cli-var-priority"),
|
||||||
|
WithVar("CLI_VAR", "from_cli"),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRequires(t *testing.T) {
|
func TestRequires(t *testing.T) {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
3.46.1
|
3.46.2
|
||||||
|
|||||||
7
testdata/vars/Taskfile.yml
vendored
7
testdata/vars/Taskfile.yml
vendored
@@ -49,3 +49,10 @@ tasks:
|
|||||||
- echo "{{.MESSAGE}}"
|
- echo "{{.MESSAGE}}"
|
||||||
|
|
||||||
from-dot-env: echo '{{.DOT_ENV_VAR}}'
|
from-dot-env: echo '{{.DOT_ENV_VAR}}'
|
||||||
|
|
||||||
|
# Test that CLI variables take priority over Taskfile defaults
|
||||||
|
cli-var-priority:
|
||||||
|
vars:
|
||||||
|
CLI_VAR: '{{.CLI_VAR | default "default_value"}}'
|
||||||
|
cmds:
|
||||||
|
- echo '{{.CLI_VAR}}'
|
||||||
|
|||||||
1
testdata/vars/testdata/TestVars-cli-var-priority-default.golden
vendored
Normal file
1
testdata/vars/testdata/TestVars-cli-var-priority-default.golden
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
default_value
|
||||||
1
testdata/vars/testdata/TestVars-cli-var-priority-override.golden
vendored
Normal file
1
testdata/vars/testdata/TestVars-cli-var-priority-override.golden
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from_cli
|
||||||
@@ -7,7 +7,12 @@ outline: deep
|
|||||||
|
|
||||||
::: v-pre
|
::: v-pre
|
||||||
|
|
||||||
## v3.46.0 - 2025-12-18
|
## v3.46.2 - 2025-12-18
|
||||||
|
|
||||||
|
- Fixed a regression on previous release that affected variables passed via
|
||||||
|
command line (#2588, #2589 by @vmaerten).
|
||||||
|
|
||||||
|
## v3.46.1 - 2025-12-18
|
||||||
|
|
||||||
### ✨ Features
|
### ✨ Features
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user