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": {}, "break": {},
"other": {}, "other": {},
} }
for i, commitInfo := range info {
for _, commitInfo := range info {
msg := commitInfo.Commit.Message msg := commitInfo.Commit.Message
index := strings.Index(fmt.Sprintf("%q", msg), `\n`) index := strings.Index(fmt.Sprintf("%q", msg), `\n`)
if index != -1 { if index != -1 {
msg = commitInfo.Commit.Message[:index-1] msg = msg[:index-1]
} }
prefix := []string{"fix", "feat", "deps", "break"} prefix := []string{"fix", "feat", "deps", "break"}
var matched bool
for _, v := range prefix { for _, v := range prefix {
if strings.HasPrefix(msg, v) { if strings.HasPrefix(msg, v) {
group[v] = append(group[v], msg) group[v] = append(group[v], msg)
info = append(info[:i], info[i+1:]...) matched = true
} }
} }
} if !matched {
// other group["other"] = append(group["other"], msg)
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]
} }
group["other"] = append(group["other"], msg)
} }
md := make(map[string]string) md := make(map[string]string)
for key, value := range group { for key, value := range group {
var text string var text string
@ -223,4 +220,4 @@ func ParseGithubUrl(url string) (owner string, repo string) {
func fatal(err error) { func fatal(err error) {
fmt.Fprintf(os.Stderr, "\033[31mERROR: %s\033[m\n", err) fmt.Fprintf(os.Stderr, "\033[31mERROR: %s\033[m\n", err)
os.Exit(1) os.Exit(1)
} }
Loading…
Cancel
Save