feat: commitmsg parser
This commit is contained in:
parent
175685c074
commit
72208487b0
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage"
|
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage"
|
||||||
"github.com/go-git/go-git/v5"
|
"github.com/go-git/go-git/v5"
|
||||||
|
@ -84,7 +85,23 @@ func commitMsgToConf() (conf Conf, err error) {
|
||||||
}
|
}
|
||||||
msg := commit.Message
|
msg := commit.Message
|
||||||
slog.Debug("commit msg to conf", "msg", msg)
|
slog.Debug("commit msg to conf", "msg", msg)
|
||||||
// TODO: parse msg to conf name
|
line := strings.Split(msg, "\n")[0]
|
||||||
conf, err = parseConfFile("conf.toml")
|
|
||||||
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user