feat: support groups in stages
This commit is contained in:
parent
fce18b60cf
commit
7e12c333b5
|
@ -198,13 +198,21 @@ func MatchGroups(conf *Conf, conventionalCommit *ConventionalCommit) []string {
|
|||
confStages = append(confStages, conf.Stage.Stages...)
|
||||
confStages = append(confStages, conf.Stage.PostStages...)
|
||||
for _, stage := range confStages {
|
||||
if stage.Group == "" {
|
||||
continue
|
||||
if stage.Group != "" {
|
||||
keyword := strings.ToLower(stage.Group)
|
||||
if _, exists := seen[keyword]; !exists {
|
||||
seen[keyword] = true
|
||||
keywords = append(keywords, keyword)
|
||||
}
|
||||
}
|
||||
keyword := strings.ToLower(stage.Group)
|
||||
if _, exists := seen[keyword]; !exists {
|
||||
seen[keyword] = true
|
||||
keywords = append(keywords, keyword)
|
||||
if len(stage.Groups) > 0 {
|
||||
for _, group := range stage.Groups {
|
||||
keyword := strings.ToLower(group)
|
||||
if _, exists := seen[keyword]; !exists {
|
||||
seen[keyword] = true
|
||||
keywords = append(keywords, keyword)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
slog.Info("group keywords from stages", "keywords", keywords)
|
||||
|
|
|
@ -6,7 +6,8 @@ import (
|
|||
|
||||
type ConfStage struct {
|
||||
Name string
|
||||
Group string
|
||||
Group string // TODO: remove Group in the future
|
||||
Groups []string
|
||||
Executor struct {
|
||||
Name string
|
||||
With struct {
|
||||
|
|
|
@ -47,19 +47,32 @@ func generateStages(confStages []conf.ConfStage, groups []string) (
|
|||
if s.Name == "" {
|
||||
s.Name = fmt.Sprintf("stage-%d", i)
|
||||
}
|
||||
var ok bool
|
||||
if s.Group != "" {
|
||||
var ok bool
|
||||
for _, group := range groups {
|
||||
if strings.EqualFold(group, s.Group) {
|
||||
ok = true
|
||||
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 {
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user