feat(parser): unify default init score = 0 (#73)
All checks were successful
submodules sync / sync (push) Successful in 36s
build / build (push) Successful in 1m28s
build / trigger-build-image (push) Successful in 7s

This commit is contained in:
张泊明518370910136 2024-11-01 03:13:38 -04:00
parent 6a7787a974
commit 5de4c3ee78
GPG Key ID: D47306D7062CDA9D
3 changed files with 9 additions and 4 deletions

View File

@ -14,7 +14,7 @@ type Match struct {
} }
type Conf struct { type Conf struct {
Score int `default:"100"` Score int
RootDir string `default:"/w"` RootDir string `default:"/w"`
Matches []Match Matches []Match
Stdout string `default:"stdout"` Stdout string `default:"stdout"`

View File

@ -17,7 +17,7 @@ type Match struct {
} }
type Conf struct { type Conf struct {
Score int `default:"100"` Score int
Matches []Match Matches []Match
Stdout string `default:"stdout"` Stdout string `default:"stdout"`
Stderr string `default:"stderr"` Stderr string `default:"stderr"`

View File

@ -13,7 +13,8 @@ type Match struct {
} }
type Conf struct { type Conf struct {
FullScore int Score int
FullScore int // TODO: remove me
MinScore int MinScore int
Files []string Files []string
ForceQuitOnMatch bool ForceQuitOnMatch bool
@ -25,7 +26,7 @@ type Keyword struct{}
func Parse(executorResult stage.ExecutorResult, conf Conf) ( func Parse(executorResult stage.ExecutorResult, conf Conf) (
stage.ParserResult, bool, stage.ParserResult, bool,
) { ) {
score := conf.FullScore score := conf.Score
comment := "" comment := ""
matched := false matched := false
for _, file := range conf.Files { for _, file := range conf.Files {
@ -54,6 +55,10 @@ func (*Keyword) Run(results []stage.ExecutorResult, confAny any) (
if err != nil { if err != nil {
return nil, true, err return nil, true, err
} }
// TODO: remove me on FullScore field removed
if conf.FullScore != 0 && conf.Score == 0 {
conf.Score = conf.FullScore
}
var res []stage.ParserResult var res []stage.ParserResult
forceQuit := false forceQuit := false
for _, result := range results { for _, result := range results {