Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: task level vars are not ignored in requires #1960

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ func TestRequires(t *testing.T) {
vars.Set("foo", ast.Var{Value: "one"})
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "validation-var", Vars: vars}))
buff.Reset()

require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "var-defined-in-task"}))
buff.Reset()
}

func TestSpecialVars(t *testing.T) {
Expand Down
8 changes: 8 additions & 0 deletions testdata/requires/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ tasks:
- foo
cmd: echo "{{.foo}}"

var-defined-in-task:
vars:
foo: bar
requires:
vars:
- foo
cmd: echo "{{.foo}}"


validation-var:
requires:
Expand Down
2 changes: 1 addition & 1 deletion variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (e *Executor) compiledTask(call *ast.Call, evaluateShVars bool) (*ast.Task,
Dir: templater.Replace(origTask.Dir, cache),
Set: origTask.Set,
Shopt: origTask.Shopt,
Vars: nil,
Vars: vars,
Env: nil,
Dotenv: templater.Replace(origTask.Dotenv, cache),
Silent: origTask.Silent,
Expand Down
Loading