From 1bd5aa6bd52af905b4012d68918996e922969fb9 Mon Sep 17 00:00:00 2001 From: Timothy Rule <34501912+trulede@users.noreply.github.com> Date: Sun, 25 Jan 2026 16:06:13 +0100 Subject: [PATCH] fix: correct the value of ROOT_TASKFILE when no entrypoint (#2635) --- executor_test.go | 1 + setup.go | 1 + testdata/special_vars/Taskfile.yml | 1 + ...lVars-testdata-special_vars-subdir-print-root-taskfile.golden | 1 + ...tSpecialVars-testdata-special_vars-print-root-taskfile.golden | 1 + 5 files changed, 5 insertions(+) create mode 100644 testdata/special_vars/subdir/testdata/TestSpecialVars-testdata-special_vars-subdir-print-root-taskfile.golden create mode 100644 testdata/special_vars/testdata/TestSpecialVars-testdata-special_vars-print-root-taskfile.golden diff --git a/executor_test.go b/executor_test.go index e7b8d027..d311e422 100644 --- a/executor_test.go +++ b/executor_test.go @@ -364,6 +364,7 @@ func TestSpecialVars(t *testing.T) { // Root "print-task", "print-root-dir", + "print-root-taskfile", "print-taskfile", "print-taskfile-dir", "print-task-dir", diff --git a/setup.go b/setup.go index 47c3c7b7..b2188387 100644 --- a/setup.go +++ b/setup.go @@ -67,6 +67,7 @@ func (e *Executor) getRootNode() (taskfile.Node, error) { return nil, err } e.Dir = node.Dir() + e.Entrypoint = node.Location() return node, err } diff --git a/testdata/special_vars/Taskfile.yml b/testdata/special_vars/Taskfile.yml index 3a650f50..71f00623 100644 --- a/testdata/special_vars/Taskfile.yml +++ b/testdata/special_vars/Taskfile.yml @@ -11,6 +11,7 @@ tasks: cmds: - echo {{.TASK}} print-root-dir: echo {{.ROOT_DIR}} + print-root-taskfile: echo {{.ROOT_TASKFILE}} print-taskfile: echo {{.TASKFILE}} print-taskfile-dir: echo {{.TASKFILE_DIR}} print-task-version: echo {{.TASK_VERSION}} diff --git a/testdata/special_vars/subdir/testdata/TestSpecialVars-testdata-special_vars-subdir-print-root-taskfile.golden b/testdata/special_vars/subdir/testdata/TestSpecialVars-testdata-special_vars-subdir-print-root-taskfile.golden new file mode 100644 index 00000000..7593e0b1 --- /dev/null +++ b/testdata/special_vars/subdir/testdata/TestSpecialVars-testdata-special_vars-subdir-print-root-taskfile.golden @@ -0,0 +1 @@ +{{.TEST_DIR}}/testdata/special_vars/Taskfile.yml diff --git a/testdata/special_vars/testdata/TestSpecialVars-testdata-special_vars-print-root-taskfile.golden b/testdata/special_vars/testdata/TestSpecialVars-testdata-special_vars-print-root-taskfile.golden new file mode 100644 index 00000000..7593e0b1 --- /dev/null +++ b/testdata/special_vars/testdata/TestSpecialVars-testdata-special_vars-print-root-taskfile.golden @@ -0,0 +1 @@ +{{.TEST_DIR}}/testdata/special_vars/Taskfile.yml