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
pull/1154/head
包子 3 years ago committed by GitHub
parent 6f1640b81d
commit a7a8d5d91a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      cmd/kratos/internal/base/get.go

@ -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…
Cancel
Save