From 7ae2bb3c10accdf18a872079ec923f2a36d5e31e Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 27 Jul 2025 10:05:18 +0000 Subject: [PATCH] fix: fixed length line numbering when displaying schema validation errors (#741) Otherwise the indentation does not show correctly. Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/741 Reviewed-by: Gusted Reviewed-by: Michael Kriese Co-authored-by: Earl Warren Co-committed-by: Earl Warren --- internal/app/run/runner.go | 2 +- internal/app/run/runner_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/app/run/runner.go b/internal/app/run/runner.go index 05a02163..20dd1106 100644 --- a/internal/app/run/runner.go +++ b/internal/app/run/runner.go @@ -190,7 +190,7 @@ func logAndReport(reporter *report.Reporter, message string, args ...any) { func explainFailedGenerateWorkflow(task *runnerv1.Task, log func(message string, args ...any), err error) error { for n, line := range strings.Split(string(task.WorkflowPayload), "\n") { - log("%d: %s", n+1, line) + log("%5d: %s", n+1, line) } log("Errors were found and although they tend to be cryptic the line number they refer to gives a hint as to where the problem might be.") for _, line := range strings.Split(err.Error(), "\n") { diff --git a/internal/app/run/runner_test.go b/internal/app/run/runner_test.go index 78348fc2..ae0470c9 100644 --- a/internal/app/run/runner_test.go +++ b/internal/app/run/runner_test.go @@ -23,7 +23,7 @@ func TestExplainFailedGenerateWorkflow(t *testing.T) { generateWorkflowError := errors.New("message 1\nmessage 2") err := explainFailedGenerateWorkflow(task, log, generateWorkflowError) assert.Error(t, err) - assert.Equal(t, "1: on: [push]\n2: jobs:\n3: \nErrors were found and although they tend to be cryptic the line number they refer to gives a hint as to where the problem might be.\nmessage 1\nmessage 2\n", logged) + assert.Equal(t, " 1: on: [push]\n 2: jobs:\n 3: \nErrors were found and although they tend to be cryptic the line number they refer to gives a hint as to where the problem might be.\nmessage 1\nmessage 2\n", logged) } func TestLabelUpdate(t *testing.T) {