Skip to content

Commit

Permalink
Fix changelog pr (#29)
Browse files Browse the repository at this point in the history
* Small fixes

(cherry picked from commit 823968ee38758d2efe3a65b45a269aae3899bb4c)

* Refactor

* Remove dependency on testutils

* Make sure markdown always ends with new lines

* Initialize changelog
  • Loading branch information
Rick Ducott authored Feb 28, 2019
1 parent 3f2665b commit 03e2e6f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
7 changes: 7 additions & 0 deletions changelog/v0.2.8/1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
changelog:
- type: FIX
description: Markdown generation now always ends in two new lines.
issueLink: https://github.com/solo-io/go-utils/issues/30
- type: NEW_FEATURE
description: Changelog now enabled for this repo.
issueLink: https://github.com/solo-io/go-utils/issues/31
12 changes: 8 additions & 4 deletions changelogutils/changelog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ var _ = Describe("ChangelogTest", func() {
- fixes foo (foo)
- fixes foo2 (foo2)
closing`
closing
`
Expect(output).To(BeEquivalentTo(expected))
})

Expand All @@ -276,7 +278,9 @@ closing`
- fixes foo2 (foo2)
closing`
closing
`
Expect(output).To(BeEquivalentTo(expected))
})

Expand All @@ -292,15 +296,15 @@ closing`
changelog := getChangelog("v0.0.1", "", "",
getChangelogFile(getEntry(changelogutils.NON_USER_FACING, "fixes foo2", "foo2")))
output := changelogutils.GenerateChangelogMarkdown(changelog)
expected := "This release contained no user-facing changes."
expected := "This release contained no user-facing changes.\n\n"
Expect(output).To(BeEquivalentTo(expected))
})

It("allows non user facing changes to not have a description or link", func() {
changelog := getChangelog("v0.0.1", "", "",
getChangelogFile(getEntry(changelogutils.NON_USER_FACING, "", "")))
output := changelogutils.GenerateChangelogMarkdown(changelog)
expected := "This release contained no user-facing changes."
expected := "This release contained no user-facing changes.\n\n"
Expect(output).To(BeEquivalentTo(expected))
})
})
Expand Down
6 changes: 4 additions & 2 deletions changelogutils/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ func GenerateChangelogMarkdown(changelog *Changelog) string {
output = output + "**Fixes**\n\n" + fixes + "\n"
}

output = output + changelog.Closing
if changelog.Closing != "" {
output = output + changelog.Closing + "\n\n"
}

if output == "" {
output = "This release contained no user-facing changes."
output = "This release contained no user-facing changes.\n\n"
}
return output
}
Expand Down
2 changes: 1 addition & 1 deletion docsutils/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func getChangelogFile(product, project string) string {
func updateChangelogFile(fs afero.Fs, product, project, markdown, tag string) error {
changelogDir := getChangelogDir(product)
changelogFile := getChangelogFile(product, project)
newContents := fmt.Sprintf("### %s\n\n%s\n\n", tag, markdown)
newContents := fmt.Sprintf("### %s\n\n%s", tag, markdown)
exists, err := afero.Exists(fs, changelogFile)
if err != nil {
return err
Expand Down

0 comments on commit 03e2e6f

Please sign in to comment.