@@ -14,13 +14,13 @@ import (
1414)
1515
1616const (
17- // ConfFileName represent config file name
18- ConfFileName = "commitlint.yaml"
17+ // DefaultFile represent default config file name
18+ DefaultFile = "commitlint.yaml"
1919)
2020
2121// GetConfig returns parses config file, validate it and returns config instance
2222func GetConfig (confPath string ) (* lint.Config , error ) {
23- confFilePath , useDefault , err := GetConfigPath (confPath )
23+ confFilePath , useDefault , err := getConfigPath (confPath )
2424 if err != nil {
2525 return nil , err
2626 }
@@ -41,19 +41,19 @@ func GetConfig(confPath string) (*lint.Config, error) {
4141 return conf , nil
4242}
4343
44- // GetConfigPath returns config file path following below order
44+ // getConfigPath returns config file path following below order
4545// 1. commitlint.yaml in current directory
4646// 2. confFilePath parameter
4747// 3. use default config
48- func GetConfigPath (confFilePath string ) (string , bool , error ) {
48+ func getConfigPath (confFilePath string ) (confPath string , isDefault bool , retErr error ) {
4949 // get current directory
5050 currentDir , err := os .Getwd ()
5151 if err != nil {
5252 return "" , false , err
5353 }
5454
5555 // check if conf file exists in current directory
56- currentDirConf := filepath .Join (currentDir , ConfFileName )
56+ currentDirConf := filepath .Join (currentDir , DefaultFile )
5757 if _ , err1 := os .Stat (currentDirConf ); ! os .IsNotExist (err1 ) {
5858 return currentDirConf , false , nil
5959 }
@@ -112,26 +112,6 @@ func Validate(conf *lint.Config) error {
112112 return nil
113113}
114114
115- // DefaultConfToFile writes default config to given file
116- func DefaultConfToFile (isOnlyEnabled bool ) error {
117- outPath := filepath .Join ("." , filepath .Clean (ConfFileName ))
118- if ! isOnlyEnabled {
119- return WriteConfToFile (outPath , defConf )
120- }
121-
122- confClone := & lint.Config {
123- Formatter : defConf .Formatter ,
124- Rules : map [string ]lint.RuleConfig {},
125- }
126-
127- for ruleName , r := range defConf .Rules {
128- if r .Enabled {
129- confClone .Rules [ruleName ] = r
130- }
131- }
132- return WriteConfToFile (outPath , confClone )
133- }
134-
135115// WriteConfToFile util func to write config object to given file
136116func WriteConfToFile (outFilePath string , conf * lint.Config ) (retErr error ) {
137117 file , err := os .Create (outFilePath )
0 commit comments