fix: print prefix when task is up-to-date and output-style is prefixed (#2633)

This commit is contained in:
Timothy Rule
2026-01-18 12:42:18 +01:00
committed by GitHub
parent fb784f4e3d
commit d5f071c096
5 changed files with 35 additions and 1 deletions

View File

@@ -717,6 +717,27 @@ func TestLabel(t *testing.T) {
)
}
func TestPrefix(t *testing.T) {
t.Parallel()
NewExecutorTest(t,
WithName("up to date"),
WithExecutorOptions(
task.WithDir("testdata/prefix_uptodate"),
task.WithOutputStyle(ast.Output{Name: "prefixed"}),
),
WithTask("foo"),
)
NewExecutorTest(t,
WithName("up to dat with no output style"),
WithExecutorOptions(
task.WithDir("testdata/prefix_uptodate"),
),
WithTask("foo"),
)
}
func TestPromptInSummary(t *testing.T) {
t.Parallel()

View File

@@ -186,7 +186,11 @@ func (e *Executor) RunTask(ctx context.Context, call *Call) error {
if upToDate && preCondMet {
if e.Verbose || (!call.Silent && !t.Silent && !e.Taskfile.Silent && !e.Silent) {
e.Logger.Errf(logger.Magenta, "task: Task %q is up to date\n", t.Name())
name := t.Name()
if e.OutputStyle.Name == "prefixed" {
name = t.Prefix
}
e.Logger.Errf(logger.Magenta, "task: Task %q is up to date\n", name)
}
return nil
}

7
testdata/prefix_uptodate/Taskfile.yml vendored Normal file
View File

@@ -0,0 +1,7 @@
version: '3'
tasks:
foo:
prefix: "foobar"
status:
- echo "I'm ok"

View File

@@ -0,0 +1 @@
task: Task "foo" is up to date

View File

@@ -0,0 +1 @@
task: Task "foobar" is up to date