feat(convention): remove directly access conventional commit
parent
5701a6d5c4
commit
84c73e3eef
|
@ -70,14 +70,14 @@ func (g *MarkdownGenerator) getNewNodes(commits []convention.Commit) []markdown.
|
|||
commitBases[othersType] = make([]markdown.Node, 0, defaultNodesLen)
|
||||
|
||||
for _, commit := range commits {
|
||||
t := getType(commit.Type)
|
||||
t := getType(commit.GetType())
|
||||
switch t {
|
||||
case addedType:
|
||||
commitBases[addedType] = append(commitBases[addedType], markdown.NewListItem(commit.RawHeader))
|
||||
commitBases[addedType] = append(commitBases[addedType], markdown.NewListItem(commit.String()))
|
||||
case fixedType:
|
||||
commitBases[fixedType] = append(commitBases[fixedType], markdown.NewListItem(commit.RawHeader))
|
||||
commitBases[fixedType] = append(commitBases[fixedType], markdown.NewListItem(commit.String()))
|
||||
case othersType:
|
||||
commitBases[othersType] = append(commitBases[othersType], markdown.NewListItem(commit.RawHeader))
|
||||
commitBases[othersType] = append(commitBases[othersType], markdown.NewListItem(commit.String()))
|
||||
default:
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -13,9 +13,7 @@ import (
|
|||
// [optional body]
|
||||
// [optional footer(s)]
|
||||
|
||||
var (
|
||||
headerRegex = regexp.MustCompile(`(?P<type>[a-zA-Z]+)(?P<scope>\([a-zA-Z]+\))?(?P<attention>!)?:\s(?P<description>.+)`)
|
||||
)
|
||||
var headerRegex = regexp.MustCompile(`(?P<type>[a-zA-Z]+)(?P<scope>\([a-zA-Z]+\))?(?P<attention>!)?:\s(?P<description>.+)`)
|
||||
|
||||
type Commit struct {
|
||||
RawHeader string
|
||||
|
@ -38,6 +36,14 @@ func NewCommit(c git.Commit) (result Commit, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (c Commit) GetType() string {
|
||||
return c.Type
|
||||
}
|
||||
|
||||
func (c Commit) String() string {
|
||||
return c.RawHeader
|
||||
}
|
||||
|
||||
func parseHeader(header string, commit *Commit) error {
|
||||
if !headerRegex.MatchString(header) {
|
||||
return errors.New("wrong header format")
|
||||
|
|
Loading…
Reference in New Issue