Compare commits

..

No commits in common. "d0b1341af01c2dd4cb7608fb2327e84b8120de69" and "d79d9ae4bdbc488f72fd4a08da0f166fed1d7577" have entirely different histories.

2 changed files with 18 additions and 23 deletions

View File

@ -164,10 +164,15 @@ func ParseMsg(confRoot, confName, msg string) (conf Conf, group string, err erro
return
}
func ListValidScopes(confRoot, confName string) ([]string, error) {
func ListValidScopes(confRoot, confName, msg string) ([]string, error) {
conventionalCommit, err := parseConventionalCommit(msg)
if err != nil {
return []string{}, err
}
slog.Info("conventional commit", "commit", conventionalCommit)
confRoot = filepath.Clean(confRoot)
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 {
slog.Error("list valid scopes", "error", err)
return err

View File

@ -4,7 +4,6 @@ import (
"flag"
"fmt"
"log/slog"
"os"
"github.com/joint-online-judge/JOJ3/cmd/joj3/conf"
"github.com/joint-online-judge/JOJ3/cmd/joj3/stage"
@ -26,15 +25,15 @@ func init() {
showVersion = flag.Bool("version", false, "print current version")
}
func mainImpl() error {
func main() {
if err := setupSlog(""); err != nil { // before conf is loaded
slog.Error("setup slog", "error", err)
return err
return
}
flag.Parse()
if *showVersion {
fmt.Println(Version)
return nil
return
}
slog.Info("start joj3", "version", Version)
if msg == "" {
@ -42,40 +41,31 @@ func mainImpl() error {
msg, err = conf.GetCommitMsg()
if err != nil {
slog.Error("get commit msg", "error", err)
return err
return
}
}
confObj, group, err := conf.ParseMsg(confRoot, confName, msg)
if err != nil {
slog.Error("parse msg", "error", err)
validScopes, scopeErr := conf.ListValidScopes(
confRoot, confName)
confRoot, confName, msg)
if scopeErr != nil {
slog.Error("list valid scopes", "error", scopeErr)
return err
return
}
slog.Info("HINT: use valid scopes in commit message",
"valid scopes", validScopes)
return err
slog.Info("hint: valid scopes in commit message", "scopes", validScopes)
return
}
if err := setupSlog(confObj.LogPath); err != nil { // after conf is loaded
slog.Error("setup slog", "error", err)
return err
return
}
if err := stage.Run(confObj, group); err != nil {
slog.Error("stage run", "error", err)
return err
return
}
if err := teapot.Run(confObj); err != nil {
slog.Error("teapot run", "error", err)
return err
}
return nil
}
func main() {
if err := mainImpl(); err != nil {
slog.Error("main exit", "error", err)
os.Exit(1)
return
}
}