feat(parser/file): force quit on non empty conf
All checks were successful
submodules sync / sync (push) Successful in 46s
build / build (push) Successful in 1m34s
build / trigger-build-image (push) Successful in 10s

This commit is contained in:
张泊明518370910136 2024-12-04 06:35:39 -05:00
parent 868154b440
commit 5abda79a54
GPG Key ID: D47306D7062CDA9D

View File

@ -7,7 +7,8 @@ import (
) )
type Conf struct { type Conf struct {
Name string Name string
ForceQuitOnNonEmpty bool
} }
type File struct{} type File struct{}
@ -20,12 +21,16 @@ func (*File) Run(results []stage.ExecutorResult, confAny any) (
return nil, true, err return nil, true, err
} }
var res []stage.ParserResult var res []stage.ParserResult
forceQuit := false
for _, result := range results { for _, result := range results {
content := result.Files[conf.Name] content := result.Files[conf.Name]
if conf.ForceQuitOnNonEmpty && content != "" {
forceQuit = true
}
if !strings.HasSuffix(content, "\n") { if !strings.HasSuffix(content, "\n") {
content += "\n" content += "\n"
} }
res = append(res, stage.ParserResult{Score: 0, Comment: content}) res = append(res, stage.ParserResult{Score: 0, Comment: content})
} }
return res, false, nil return res, forceQuit, nil
} }