1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-15 18:57:01 +00:00

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 <gusted@noreply.code.forgejo.org>
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
Earl Warren 2025-07-27 10:05:18 +00:00 committed by earl-warren
parent e81664ec7b
commit 7ae2bb3c10
No known key found for this signature in database
GPG key ID: F128CBE6AB3A7201
2 changed files with 2 additions and 2 deletions

View file

@ -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") {

View file

@ -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) {