feat(cmd/joj3): grab keywords from groups
This commit is contained in:
		
							parent
							
								
									23c9f3d453
								
							
						
					
					
						commit
						1751e906da
					
				|  | @ -35,10 +35,9 @@ type ConfStage struct { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type Conf struct { | 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 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user