feat: support groups in stages
Some checks failed
submodules sync / sync (push) Successful in 51s
build / build (push) Failing after 2m23s
build / trigger-build-image (push) Has been skipped

This commit is contained in:
张泊明518370910136 2025-09-24 03:13:17 -07:00
parent fce18b60cf
commit 7e12c333b5
GPG Key ID: D47306D7062CDA9D
3 changed files with 33 additions and 11 deletions

View File

@ -198,13 +198,21 @@ func MatchGroups(conf *Conf, conventionalCommit *ConventionalCommit) []string {
confStages = append(confStages, conf.Stage.Stages...) confStages = append(confStages, conf.Stage.Stages...)
confStages = append(confStages, conf.Stage.PostStages...) confStages = append(confStages, conf.Stage.PostStages...)
for _, stage := range confStages { for _, stage := range confStages {
if stage.Group == "" { if stage.Group != "" {
continue keyword := strings.ToLower(stage.Group)
if _, exists := seen[keyword]; !exists {
seen[keyword] = true
keywords = append(keywords, keyword)
}
} }
keyword := strings.ToLower(stage.Group) if len(stage.Groups) > 0 {
if _, exists := seen[keyword]; !exists { for _, group := range stage.Groups {
seen[keyword] = true keyword := strings.ToLower(group)
keywords = append(keywords, keyword) if _, exists := seen[keyword]; !exists {
seen[keyword] = true
keywords = append(keywords, keyword)
}
}
} }
} }
slog.Info("group keywords from stages", "keywords", keywords) slog.Info("group keywords from stages", "keywords", keywords)

View File

@ -6,7 +6,8 @@ import (
type ConfStage struct { type ConfStage struct {
Name string Name string
Group string Group string // TODO: remove Group in the future
Groups []string
Executor struct { Executor struct {
Name string Name string
With struct { With struct {

View File

@ -47,19 +47,32 @@ func generateStages(confStages []conf.ConfStage, groups []string) (
if s.Name == "" { if s.Name == "" {
s.Name = fmt.Sprintf("stage-%d", i) s.Name = fmt.Sprintf("stage-%d", i)
} }
var ok bool
if s.Group != "" { if s.Group != "" {
var ok bool
for _, group := range groups { for _, group := range groups {
if strings.EqualFold(group, s.Group) { if strings.EqualFold(group, s.Group) {
ok = true ok = true
break break
} }
} }
if !ok { }
continue if !ok && len(s.Groups) > 0 {
for _, group := range groups {
for _, g := range s.Groups {
if strings.EqualFold(group, g) {
ok = true
break
}
}
if ok {
break
}
} }
} }
_, ok := existNames[s.Name] // check for existence if !ok {
continue
}
_, ok = existNames[s.Name] // check for existence
if ok { if ok {
continue continue
} }