diff --git a/cmd/joj3/conf/conf.go b/cmd/joj3/conf/conf.go index f8e6837..2f1c94e 100644 --- a/cmd/joj3/conf/conf.go +++ b/cmd/joj3/conf/conf.go @@ -228,10 +228,10 @@ func ParseMsg(confRoot, confName, msg, tag string) (confPath, group string, err return } -func ListValidScopes(confRoot, confName string) ([]string, error) { +func HintValidScopes(confRoot, confName string) { confRoot = filepath.Clean(confRoot) validScopes := []string{} - err := filepath.Walk(confRoot, func( + _ = filepath.Walk(confRoot, func( path string, info os.FileInfo, err error, ) error { if err != nil { @@ -254,7 +254,8 @@ func ListValidScopes(confRoot, confName string) ([]string, error) { } return nil }) - return validScopes, err + slog.Info("HINT: use valid scopes in commit message", + "valid scopes", validScopes) } func CheckExpire(conf *Conf) error { diff --git a/cmd/joj3/main.go b/cmd/joj3/main.go index 74fa4a7..4fe6b1e 100644 --- a/cmd/joj3/main.go +++ b/cmd/joj3/main.go @@ -48,20 +48,16 @@ func mainImpl() error { confPath, group, err := conf.ParseMsg(confRoot, confName, msg, tag) if err != nil { slog.Error("parse msg", "error", err) - validScopes, scopeErr := conf.ListValidScopes( - confRoot, confName) - if scopeErr != nil { - slog.Error("list valid scopes", "error", scopeErr) - return err - } - slog.Info("HINT: use valid scopes in commit message", - "valid scopes", validScopes) + conf.HintValidScopes(confRoot, confName) return err } slog.Info("try to load conf", "path", confPath) confObj, err := conf.ParseConfFile(confPath) if err != nil { slog.Error("parse conf", "error", err) + if _, statErr := os.Stat(confPath); os.IsNotExist(statErr) { + conf.HintValidScopes(confRoot, confName) + } return err } slog.Debug("conf loaded", "conf", confObj)