feat: format commit as markdown item

main
hau 2020-11-10 17:12:13 +07:00
parent 063680ab31
commit 6a5d3fe235
5 changed files with 32 additions and 28 deletions

View File

@ -49,11 +49,11 @@ func (g *MarkdownGenerator) getLines(commits []convention.Commit) []string {
t := getType(commit.Type)
switch t {
case addedType:
addedLines = append(addedLines, commit.RawHeader)
addedLines = append(addedLines, g.composeListItem(commit.RawHeader))
case fixedType:
fixedLines = append(fixedLines, commit.RawHeader)
fixedLines = append(fixedLines, g.composeListItem(commit.RawHeader))
case othersType:
othersLines = append(othersLines, commit.RawHeader)
othersLines = append(othersLines, g.composeListItem(commit.RawHeader))
default:
continue
}
@ -73,9 +73,13 @@ func (g *MarkdownGenerator) getLines(commits []convention.Commit) []string {
func (g *MarkdownGenerator) composeVersionHeader() string {
year, month, day := g.t.Date()
return fmt.Sprintf("# %s (%d-%d-%d)", g.version, year, month, day)
return fmt.Sprintf("## %s (%d-%d-%d)", g.version, year, month, day)
}
func (g *MarkdownGenerator) composeTypeHeader(t string) string {
return fmt.Sprintf("## %s", t)
return fmt.Sprintf("### %s", t)
}
func (g *MarkdownGenerator) composeListItem(text string) string {
return fmt.Sprintf("* %s", text)
}

View File

@ -1,8 +1,8 @@
[
"# CHANGELOG",
"# v1.0.0 (1-1-1)",
"## Added",
"feat: description",
"## Fixed",
"## Others"
"## v1.0.0 (1-1-1)",
"### Added",
"* feat: description",
"### Fixed",
"### Others"
]

View File

@ -1,8 +1,8 @@
[
"# CHANGELOG",
"# v1.0.0 (1-1-1)",
"## Added",
"## Fixed",
"fix: description",
"## Others"
"## v1.0.0 (1-1-1)",
"### Added",
"### Fixed",
"* fix: description",
"### Others"
]

View File

@ -1,8 +1,8 @@
[
"# CHANGELOG",
"# v1.0.0 (1-1-1)",
"## Added",
"## Fixed",
"## Others",
"ci: description"
"## v1.0.0 (1-1-1)",
"### Added",
"### Fixed",
"### Others",
"* ci: description"
]

View File

@ -1,11 +1,11 @@
[
"# CHANGELOG",
"# v1.0.0 (1-1-1)",
"## Added",
"feat: description feat",
"## Fixed",
"fix: description fix",
"## Others",
"ci: description ci",
"build: description build"
"## v1.0.0 (1-1-1)",
"### Added",
"* feat: description feat",
"### Fixed",
"* fix: description fix",
"### Others",
"* ci: description ci",
"* build: description build"
]