Skip to content
Snippets Groups Projects
Commit 90acdb60 authored by timoknapp's avatar timoknapp Committed by Christoph Witzko
Browse files

chore: rename changlog-config to 'emojis'

parent b76f53a5
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ The changelog generator will order the types of commits in the changelog in the ...@@ -23,7 +23,7 @@ The changelog generator will order the types of commits in the changelog in the
## Prettified changelogs ## 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) [Example Change Log](./examples/GENERATED_CHANGELOG.md)
......
...@@ -28,19 +28,19 @@ func formatCommit(c *semrel.Commit) string { ...@@ -28,19 +28,19 @@ func formatCommit(c *semrel.Commit) string {
var CGVERSION = "dev" var CGVERSION = "dev"
type DefaultChangelogGenerator struct { type DefaultChangelogGenerator struct {
prettifiedOutput bool emojis bool
} }
func (g *DefaultChangelogGenerator) Init(m map[string]string) error { func (g *DefaultChangelogGenerator) Init(m map[string]string) error {
prettifiedOutput := false emojis := false
prettifyConfig := m["prettified_output"] emojiConfig := m["emojis"]
if prettifyConfig == "true" { if emojiConfig == "true" {
prettifiedOutput = true emojis = true
} }
g.prettifiedOutput = prettifiedOutput g.emojis = emojis
return nil return nil
} }
...@@ -74,11 +74,11 @@ func (g *DefaultChangelogGenerator) Generate(changelogConfig *generator.Changelo ...@@ -74,11 +74,11 @@ func (g *DefaultChangelogGenerator) Generate(changelogConfig *generator.Changelo
if ct.Content == "" { if ct.Content == "" {
continue continue
} }
prettifyPrefix := "" emojiPrefix := ""
if g.prettifiedOutput { if g.emojis && ct.Emoji != "" {
prettifyPrefix = 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 return ret
} }
...@@ -36,7 +36,7 @@ func TestDefaultGenerator(t *testing.T) { ...@@ -36,7 +36,7 @@ func TestDefaultGenerator(t *testing.T) {
} }
} }
func TestPrettifiedGenerator(t *testing.T) { func TestEmojiGenerator(t *testing.T) {
changelogConfig := &generator.ChangelogGeneratorConfig{} changelogConfig := &generator.ChangelogGeneratorConfig{}
changelogConfig.Commits = []*semrel.Commit{ changelogConfig.Commits = []*semrel.Commit{
{}, {},
...@@ -51,7 +51,7 @@ func TestPrettifiedGenerator(t *testing.T) { ...@@ -51,7 +51,7 @@ func TestPrettifiedGenerator(t *testing.T) {
} }
changelogConfig.LatestRelease = &semrel.Release{SHA: "stop"} changelogConfig.LatestRelease = &semrel.Release{SHA: "stop"}
changelogConfig.NewVersion = "2.0.0" changelogConfig.NewVersion = "2.0.0"
generator := &DefaultChangelogGenerator{prettifiedOutput: true} generator := &DefaultChangelogGenerator{emojis: true}
changelog := generator.Generate(changelogConfig) changelog := generator.Generate(changelogConfig)
if !strings.Contains(changelog, "* **app:** commit message (12345678)") || if !strings.Contains(changelog, "* **app:** commit message (12345678)") ||
!strings.Contains(changelog, "* commit message (abcd)") || !strings.Contains(changelog, "* commit message (abcd)") ||
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment