From 43f3dcea05c7f9f51fe901bff7649383580a975e Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Mon, 30 Dec 2024 18:27:16 -0300 Subject: [PATCH] chore(requires): skip unneeded variable evaluation for `requires` (#1976) --- requires.go | 9 ++------- task.go | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/requires.go b/requires.go index 156a2dc63c..c0b10edb24 100644 --- a/requires.go +++ b/requires.go @@ -7,20 +7,15 @@ import ( "github.com/go-task/task/v3/taskfile/ast" ) -func (e *Executor) areTaskRequiredVarsSet(t *ast.Task, call *ast.Call) error { +func (e *Executor) areTaskRequiredVarsSet(t *ast.Task) error { if t.Requires == nil || len(t.Requires.Vars) == 0 { return nil } - vars, err := e.Compiler.GetVariables(t, call) - if err != nil { - return err - } - var missingVars []string var notAllowedValuesVars []errors.NotAllowedVar for _, requiredVar := range t.Requires.Vars { - value, ok := vars.Get(requiredVar.Name) + value, ok := t.Vars.Get(requiredVar.Name) if !ok { missingVars = append(missingVars, requiredVar.Name) } else { diff --git a/task.go b/task.go index f4e1527942..f893a9ee48 100644 --- a/task.go +++ b/task.go @@ -176,7 +176,7 @@ func (e *Executor) RunTask(ctx context.Context, call *ast.Call) error { return nil } - if err := e.areTaskRequiredVarsSet(t, call); err != nil { + if err := e.areTaskRequiredVarsSet(t); err != nil { return err }