diff --git a/README.md b/README.md index 67a4dc5b440e1e5956452ae5cf564001bc0931ad..886631f22ac07eb0e672e9f94291ffefd5f3c177 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ The changelog generator will order the types of commits in the changelog in the ## Prettified changelogs -In order to use prettified changelogs including a prefixed emoji, you need to provide the following config when calling semantic-relase: `--changelog-generator-opt "prettified_output=true"`. Or add the config within your `.semrelrc` file. +In order to use prettified changelogs including a prefixed emoji, you need to provide the following config when calling semantic-relase: `--changelog-generator-opt "emojis=true"`. Or add the config within your `.semrelrc` file. [Example Change Log](./examples/GENERATED_CHANGELOG.md) diff --git a/examples/GENERATED_CHANGELOG.md b/examples/GENERATED_CHANGELOG.md index ee5598bcbaeb3b1cdcea78a6182b59f17271d0fe..6aa571c29e10b7c3e86a72bd71eb18bdb046ec0e 100644 --- a/examples/GENERATED_CHANGELOG.md +++ b/examples/GENERATED_CHANGELOG.md @@ -23,7 +23,7 @@ changed ID int into UUID * commit message (43218765) -#### 🔁 CI +#### 🔁 CI * commit message (87654321) diff --git a/pkg/generator/changelog_generator.go b/pkg/generator/changelog_generator.go index 5b45422d7113bd92f9235263598d9dd5640ac01b..b2772a6f6baf8fd3d3dec89809989ba49c317d2d 100644 --- a/pkg/generator/changelog_generator.go +++ b/pkg/generator/changelog_generator.go @@ -28,19 +28,19 @@ func formatCommit(c *semrel.Commit) string { var CGVERSION = "dev" type DefaultChangelogGenerator struct { - prettifiedOutput bool + emojis bool } func (g *DefaultChangelogGenerator) Init(m map[string]string) error { - prettifiedOutput := false + emojis := false - prettifyConfig := m["prettified_output"] + emojiConfig := m["emojis"] - if prettifyConfig == "true" { - prettifiedOutput = true + if emojiConfig == "true" { + emojis = true } - g.prettifiedOutput = prettifiedOutput + g.emojis = emojis return nil } @@ -74,11 +74,11 @@ func (g *DefaultChangelogGenerator) Generate(changelogConfig *generator.Changelo if ct.Content == "" { continue } - prettifyPrefix := "" - if g.prettifiedOutput { - prettifyPrefix = ct.Emoji + emojiPrefix := "" + if g.emojis && ct.Emoji != "" { + emojiPrefix = fmt.Sprintf("%s ", ct.Emoji) } - ret += fmt.Sprintf("#### %s%s\n\n%s\n", prettifyPrefix, ct.Text, ct.Content) + ret += fmt.Sprintf("#### %s%s\n\n%s\n", emojiPrefix, ct.Text, ct.Content) } return ret } diff --git a/pkg/generator/changelog_generator_test.go b/pkg/generator/changelog_generator_test.go index 6f217f360199710d5ce68efb28302a4d32f8f711..57f23995381c34b5497d7680700cba247b9cefec 100644 --- a/pkg/generator/changelog_generator_test.go +++ b/pkg/generator/changelog_generator_test.go @@ -36,7 +36,7 @@ func TestDefaultGenerator(t *testing.T) { } } -func TestPrettifiedGenerator(t *testing.T) { +func TestEmojiGenerator(t *testing.T) { changelogConfig := &generator.ChangelogGeneratorConfig{} changelogConfig.Commits = []*semrel.Commit{ {}, @@ -51,7 +51,7 @@ func TestPrettifiedGenerator(t *testing.T) { } changelogConfig.LatestRelease = &semrel.Release{SHA: "stop"} changelogConfig.NewVersion = "2.0.0" - generator := &DefaultChangelogGenerator{prettifiedOutput: true} + generator := &DefaultChangelogGenerator{emojis: true} changelog := generator.Generate(changelogConfig) if !strings.Contains(changelog, "* **app:** commit message (12345678)") || !strings.Contains(changelog, "* commit message (abcd)") || diff --git a/pkg/generator/changelog_types.go b/pkg/generator/changelog_types.go index 6c9a6ad7fab8971dc5806027e2e499f97ea7c6d6..4ea54e7d2073a6326d8034e45e4e31b4c75603d7 100644 --- a/pkg/generator/changelog_types.go +++ b/pkg/generator/changelog_types.go @@ -33,61 +33,61 @@ var defaultTypes = ChangelogTypes{ { Type: "%%bc%%", Text: "Breaking Changes", - Emoji: "📣 ", + Emoji: "📣", }, { Type: "feat", Text: "Feature", - Emoji: "🎁 ", + Emoji: "🎁", }, { Type: "fix", Text: "Bug Fixes", - Emoji: "🐞 ", + Emoji: "🐞", }, { Type: "revert", Text: "Reverts", - Emoji: "🔙 ", + Emoji: "🔙", }, { Type: "perf", Text: "Performance Improvements", - Emoji: "📈 ", + Emoji: "📈", }, { Type: "docs", Text: "Documentation", - Emoji: "📄 ", + Emoji: "📄", }, { Type: "test", Text: "Tests", - Emoji: "🔎 ", + Emoji: "🔎", }, { Type: "refactor", Text: "Code Refactoring", - Emoji: "🔀 ", + Emoji: "🔀", }, { Type: "style", Text: "Styles", - Emoji: "🎨 ", + Emoji: "🎨", }, { Type: "chore", Text: "Chores", - Emoji: "🚧 ", + Emoji: "🚧", }, { Type: "build", Text: "Build", - Emoji: "📦 ", + Emoji: "📦", }, { Type: "ci", Text: "CI", - Emoji: "🔁 ", + Emoji: "🔁", }, }