From 176e35a16e01e9c4bf7ad06630fca72749189440 Mon Sep 17 00:00:00 2001 From: Tran Hau Date: Tue, 12 Jan 2021 01:37:11 +0700 Subject: [PATCH] fix: no newline at end of file --- .../TestMarkdownGeneratorGenerate/empty_old_data.golden | 2 +- .../TestMarkdownGeneratorGenerate/many_commits.golden | 2 +- pkg/markdown/generate.go | 6 ++++-- pkg/markdown/generate_test.go | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/changelog/testdata/TestMarkdownGeneratorGenerate/empty_old_data.golden b/pkg/changelog/testdata/TestMarkdownGeneratorGenerate/empty_old_data.golden index b3e7bf5..585b880 100644 --- a/pkg/changelog/testdata/TestMarkdownGeneratorGenerate/empty_old_data.golden +++ b/pkg/changelog/testdata/TestMarkdownGeneratorGenerate/empty_old_data.golden @@ -12,4 +12,4 @@ ### Others -- chore: new build \ No newline at end of file +- chore: new build diff --git a/pkg/changelog/testdata/TestMarkdownGeneratorGenerate/many_commits.golden b/pkg/changelog/testdata/TestMarkdownGeneratorGenerate/many_commits.golden index c1020d4..c445694 100644 --- a/pkg/changelog/testdata/TestMarkdownGeneratorGenerate/many_commits.golden +++ b/pkg/changelog/testdata/TestMarkdownGeneratorGenerate/many_commits.golden @@ -22,4 +22,4 @@ - chore(gitlab): release on gitlab -- unleash the dragon \ No newline at end of file +- unleash the dragon diff --git a/pkg/markdown/generate.go b/pkg/markdown/generate.go index a5b943c..e3125d4 100644 --- a/pkg/markdown/generate.go +++ b/pkg/markdown/generate.go @@ -4,10 +4,12 @@ import "strings" func Generate(bases []Node) string { lines := make([]string, len(bases)) - for i, base := range bases { lines[i] = base.String() } - return strings.Join(lines, string(NewlineToken)+string(NewlineToken)) + result := strings.Join(lines, string(NewlineToken)+string(NewlineToken)) + // Fix no newline at end of file + result += string(NewlineToken) + return result } diff --git a/pkg/markdown/generate_test.go b/pkg/markdown/generate_test.go index 86e35e8..b15fa4e 100644 --- a/pkg/markdown/generate_test.go +++ b/pkg/markdown/generate_test.go @@ -26,7 +26,7 @@ func TestGenerate(t *testing.T) { text: "item 2", }, }, - want: "# header\n\n- item 1\n\n- item 2", + want: "# header\n\n- item 1\n\n- item 2\n", }, }