From 5abda79a544572ae2903f5d4cb0c8fd3003bea2b Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Wed, 4 Dec 2024 06:35:39 -0500 Subject: [PATCH] feat(parser/file): force quit on non empty conf --- internal/parser/file/parser.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/parser/file/parser.go b/internal/parser/file/parser.go index f225a70..8eda627 100644 --- a/internal/parser/file/parser.go +++ b/internal/parser/file/parser.go @@ -7,7 +7,8 @@ import ( ) type Conf struct { - Name string + Name string + ForceQuitOnNonEmpty bool } type File struct{} @@ -20,12 +21,16 @@ func (*File) Run(results []stage.ExecutorResult, confAny any) ( return nil, true, err } var res []stage.ParserResult + forceQuit := false for _, result := range results { content := result.Files[conf.Name] + if conf.ForceQuitOnNonEmpty && content != "" { + forceQuit = true + } if !strings.HasSuffix(content, "\n") { content += "\n" } res = append(res, stage.ParserResult{Score: 0, Comment: content}) } - return res, false, nil + return res, forceQuit, nil }