@@ -27,13 +27,14 @@ type validateConfig struct {
2727 Scopes []string `json:"scopes,omitempty"`
2828}
2929
30- type empty struct {}
30+ // use type alias to avoid new type and unexpected method definition
31+ type dummy = struct {}
3132
3233var (
3334 // globalConfig ...
3435 globalConfig * validateConfig = & validateConfig {Lang : "en" , BodyRequired : false , LineLimit : 80 }
3536 // TypeSet ...
36- TypeSet = map [string ]empty {
37+ TypeSet = map [string ]dummy {
3738 "feat" : {}, // new feature 新功能
3839 "fix" : {}, // fix bug 修复
3940 "docs" : {}, // documentation 文档
@@ -81,41 +82,26 @@ func loadConfig(path string, cfg *validateConfig) *validateConfig {
8182 return cfg
8283}
8384
84- // func initConfig(path string) *globalConfig {
85- // cfg := &globalConfig{"en", false, 80}
86- // f, err := os.Create(path)
87- // if err != nil {
88- // return cfg
89- // }
90- // defer f.Close()
91- // enc := json.NewEncoder(f)
92- // enc.SetIndent("", " ")
93- // enc.Encode(cfg)
94- // return cfg
95- // }
96-
9785func init () {
9886 paths := locateConfigs ()
9987 for _ , p := range paths {
10088 // TODO: fix json value overlaping
10189 globalConfig = loadConfig (p , globalConfig )
10290 }
103- // if Config == nil {
104- // Config = initConfig(path)
105- // }
10691
10792 for _ , t := range globalConfig .Types {
108- TypeSet [t ] = empty {}
93+ TypeSet [t ] = dummy {}
10994 }
11095
11196 for _ , t := range globalConfig .DenyTypes {
11297 delete (TypeSet , t )
11398 }
11499
115- types := make ([]string , 0 , len (TypeSet ))
100+ types := make ([]string , 0 , len (TypeSet )+ 2 )
116101 for t := range TypeSet {
117102 types = append (types , t )
118103 }
104+ types = append (types , "revert" , "Revert" )
119105 TypesStr = strings .Join (types , ", " )
120106
121107 state .Init (lang .LoadLanguage (globalConfig .Lang ), TypesStr )
0 commit comments