fix(cmd/joj): show valid scopes on wrong message
All checks were successful
build / build (push) Successful in 1m45s
submodules sync / sync (push) Successful in 28s
build / trigger-build-image (push) Successful in 6s

This commit is contained in:
张泊明518370910136 2024-10-08 17:10:48 -04:00
parent e1e4fded28
commit d0b1341af0
GPG Key ID: D47306D7062CDA9D
2 changed files with 5 additions and 9 deletions

View File

@ -164,15 +164,10 @@ func ParseMsg(confRoot, confName, msg string) (conf Conf, group string, err erro
return return
} }
func ListValidScopes(confRoot, confName, msg string) ([]string, error) { func ListValidScopes(confRoot, confName string) ([]string, error) {
conventionalCommit, err := parseConventionalCommit(msg)
if err != nil {
return []string{}, err
}
slog.Info("conventional commit", "commit", conventionalCommit)
confRoot = filepath.Clean(confRoot) confRoot = filepath.Clean(confRoot)
validScopes := []string{} validScopes := []string{}
err = filepath.Walk(confRoot, func(path string, info os.FileInfo, err error) error { err := filepath.Walk(confRoot, func(path string, info os.FileInfo, err error) error {
if err != nil { if err != nil {
slog.Error("list valid scopes", "error", err) slog.Error("list valid scopes", "error", err)
return err return err

View File

@ -49,12 +49,13 @@ func mainImpl() error {
if err != nil { if err != nil {
slog.Error("parse msg", "error", err) slog.Error("parse msg", "error", err)
validScopes, scopeErr := conf.ListValidScopes( validScopes, scopeErr := conf.ListValidScopes(
confRoot, confName, msg) confRoot, confName)
if scopeErr != nil { if scopeErr != nil {
slog.Error("list valid scopes", "error", scopeErr) slog.Error("list valid scopes", "error", scopeErr)
return err return err
} }
slog.Info("hint: valid scopes in commit message", "scopes", validScopes) slog.Info("HINT: use valid scopes in commit message",
"valid scopes", validScopes)
return err return err
} }
if err := setupSlog(confObj.LogPath); err != nil { // after conf is loaded if err := setupSlog(confObj.LogPath); err != nil { // after conf is loaded