mirror of
https://github.com/go-kratos/kratos.git
synced 2025-03-17 21:07:54 +02:00
fix(cmd): fixed a problem where prefix could not be matched in some cases (#1151)
* fix(cmd): fixed a problem where prefix could not be matched in some cases
This commit is contained in:
parent
6f1640b81d
commit
a7a8d5d91a
@ -134,29 +134,26 @@ func ParseCommitsInfo(info []CommitInfo) string {
|
||||
"break": {},
|
||||
"other": {},
|
||||
}
|
||||
for i, commitInfo := range info {
|
||||
|
||||
for _, commitInfo := range info {
|
||||
msg := commitInfo.Commit.Message
|
||||
index := strings.Index(fmt.Sprintf("%q", msg), `\n`)
|
||||
if index != -1 {
|
||||
msg = commitInfo.Commit.Message[:index-1]
|
||||
msg = msg[:index-1]
|
||||
}
|
||||
prefix := []string{"fix", "feat", "deps", "break"}
|
||||
var matched bool
|
||||
for _, v := range prefix {
|
||||
if strings.HasPrefix(msg, v) {
|
||||
group[v] = append(group[v], msg)
|
||||
info = append(info[:i], info[i+1:]...)
|
||||
matched = true
|
||||
}
|
||||
}
|
||||
}
|
||||
// other
|
||||
for _, value := range info {
|
||||
msg := value.Commit.Message
|
||||
index := strings.Index(fmt.Sprintf("%q", msg), `\n`)
|
||||
if index != -1 {
|
||||
msg = value.Commit.Message[:index-1]
|
||||
if !matched {
|
||||
group["other"] = append(group["other"], msg)
|
||||
}
|
||||
group["other"] = append(group["other"], msg)
|
||||
}
|
||||
|
||||
md := make(map[string]string)
|
||||
for key, value := range group {
|
||||
var text string
|
||||
@ -223,4 +220,4 @@ func ParseGithubUrl(url string) (owner string, repo string) {
|
||||
func fatal(err error) {
|
||||
fmt.Fprintf(os.Stderr, "\033[31mERROR: %s\033[m\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user