feat(cmd/joj3): grab keywords from groups
All checks were successful
submodules sync / sync (push) Successful in 41s
build / build (push) Successful in 1m29s
build / trigger-build-image (push) Successful in 7s

This commit is contained in:
张泊明518370910136 2024-10-31 17:49:20 -04:00
parent 23c9f3d453
commit 1751e906da
GPG Key ID: D47306D7062CDA9D

View File

@ -38,7 +38,6 @@ type Conf struct {
Name string `default:"unknown"` Name string `default:"unknown"`
LogPath string `default:""` LogPath string `default:""`
ExpireUnixTimestamp int64 `default:"-1"` ExpireUnixTimestamp int64 `default:"-1"`
GroupKeywords []string `default:"joj"`
Stage struct { Stage struct {
SandboxExecServer string `default:"localhost:5051"` SandboxExecServer string `default:"localhost:5051"`
SandboxToken string `default:""` SandboxToken string `default:""`
@ -313,13 +312,15 @@ func CheckExpire(conf *Conf) error {
} }
func MatchGroups(conf *Conf, conventionalCommit *ConventionalCommit) []string { func MatchGroups(conf *Conf, conventionalCommit *ConventionalCommit) []string {
keywords := conf.GroupKeywords keywords := []string{}
for _, stage := range conf.Stage.Stages {
keywords = append(keywords, strings.ToLower(stage.Group))
}
groups := []string{} groups := []string{}
loweredDescription := strings.ToLower(conventionalCommit.Description) loweredDescription := strings.ToLower(conventionalCommit.Description)
for _, keyword := range keywords { for _, keyword := range keywords {
loweredKeyword := strings.ToLower(keyword) if strings.Contains(loweredDescription, keyword) {
if strings.Contains(loweredDescription, loweredKeyword) { groups = append(groups, keyword)
groups = append(groups, loweredKeyword)
} }
} }
return groups return groups