fix(changelog): correct get lines and skip generate if no new lines

main
hau 2020-11-11 00:06:04 +07:00
parent 9857323da0
commit e374d982f0
1 changed files with 6 additions and 2 deletions

View File

@ -32,11 +32,11 @@ func NewMarkdownGenerator(path string, version string, t time.Time) *MarkdownGen
}
func (g *MarkdownGenerator) Generate(commits []convention.Commit) error {
if len(commits) == 0 {
lines := g.getLines(commits)
if len(lines) == 0 {
return nil
}
lines := g.getLines(commits)
previousLines := g.getPreviousLines()
lines = append(lines, previousLines...)
@ -49,6 +49,10 @@ func (g *MarkdownGenerator) Generate(commits []convention.Commit) error {
}
func (g *MarkdownGenerator) getLines(commits []convention.Commit) []string {
if len(commits) == 0 {
return nil
}
lines := make([]string, 0, defaultLinesLen)
lines = append(lines, markdownTitle)
lines = append(lines, g.composeVersionHeader())