1
0
mirror of https://github.com/go-task/task.git synced 2025-04-21 12:17:07 +02:00

fix: include with dynamic vars (#2092)

This commit is contained in:
Valentin Maerten 2025-02-26 17:49:05 +01:00 committed by GitHub
parent a266fba93e
commit c23c46e326
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 1 deletions

View File

@ -2477,6 +2477,19 @@ VAR_2 is included-default-var2
assert.Equal(t, strings.TrimSpace(buff.String()), expectedOutputOrder) assert.Equal(t, strings.TrimSpace(buff.String()), expectedOutputOrder)
} }
func TestIncludeWithVarsInInclude(t *testing.T) {
t.Parallel()
const dir = "testdata/include_with_vars_inside_include"
var buff bytes.Buffer
e := task.Executor{
Dir: dir,
Stdout: &buff,
Stderr: &buff,
}
require.NoError(t, e.Setup())
}
func TestIncludedVarsMultiLevel(t *testing.T) { func TestIncludedVarsMultiLevel(t *testing.T) {
t.Parallel() t.Parallel()

View File

@ -105,7 +105,7 @@ func (vars *Vars) ToCacheMap() (m map[string]any) {
if v.Sh != nil && *v.Sh != "" { if v.Sh != nil && *v.Sh != "" {
// Dynamic variable is not yet resolved; trigger // Dynamic variable is not yet resolved; trigger
// <no value> to be used in templates. // <no value> to be used in templates.
return nil continue
} }
if v.Live != nil { if v.Live != nil {
m[k] = v.Live m[k] = v.Live

View File

@ -0,0 +1,10 @@
version: "3"
vars:
INCLUDE: include
FOO:
sh : echo bar
includes:
included1:
taskfile: '{{.INCLUDE}}/Taskfile.include.yml'

View File

@ -0,0 +1 @@
version: "3"