feat: commitmsg parser
This commit is contained in:
parent
175685c074
commit
72208487b0
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"log/slog"
|
||||
"strings"
|
||||
|
||||
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage"
|
||||
"github.com/go-git/go-git/v5"
|
||||
|
@ -84,7 +85,23 @@ func commitMsgToConf() (conf Conf, err error) {
|
|||
}
|
||||
msg := commit.Message
|
||||
slog.Debug("commit msg to conf", "msg", msg)
|
||||
// TODO: parse msg to conf name
|
||||
conf, err = parseConfFile("conf.toml")
|
||||
line := strings.Split(msg, "\n")[0]
|
||||
|
||||
words := strings.TrimSpace(line)
|
||||
head := string(words[0])
|
||||
|
||||
file := "conf.toml"
|
||||
|
||||
if strings.HasSuffix(head, ":") || strings.HasSuffix(head, ".") {
|
||||
head = head[:len(head)-1]
|
||||
}
|
||||
switch head {
|
||||
case "feat", "fix", "refactor", "perf", "test", "build", "revert":
|
||||
strings.Replace(file, "conf", "conf-cp", 1)
|
||||
case "joj", "grading":
|
||||
strings.Replace(file, "conf", "conf-oj", 1)
|
||||
}
|
||||
|
||||
conf, err = parseConfFile(file)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user