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) t := getType(commit.Type)
switch t { switch t {
case addedType: case addedType:
addedLines = append(addedLines, commit.RawHeader) addedLines = append(addedLines, g.composeListItem(commit.RawHeader))
case fixedType: case fixedType:
fixedLines = append(fixedLines, commit.RawHeader) fixedLines = append(fixedLines, g.composeListItem(commit.RawHeader))
case othersType: case othersType:
othersLines = append(othersLines, commit.RawHeader) othersLines = append(othersLines, g.composeListItem(commit.RawHeader))
default: default:
continue continue
} }
@ -73,9 +73,13 @@ func (g *MarkdownGenerator) getLines(commits []convention.Commit) []string {
func (g *MarkdownGenerator) composeVersionHeader() string { func (g *MarkdownGenerator) composeVersionHeader() string {
year, month, day := g.t.Date() 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 { 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", "# CHANGELOG",
"# v1.0.0 (1-1-1)", "## v1.0.0 (1-1-1)",
"## Added", "### Added",
"feat: description", "* feat: description",
"## Fixed", "### Fixed",
"## Others" "### Others"
] ]

View File

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

View File

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

View File

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