Skip to content

Commit 79f1a36

Browse files
timoknappchristophwitzko
authored andcommitted
chore: now also check for changelog config 'prettify' flag
1 parent ecdd4af commit 79f1a36

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

β€Žpkg/generator/changelog_generator.goβ€Ž

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,21 @@ func formatCommit(c *semrel.Commit) string {
2727

2828
var CGVERSION = "dev"
2929

30-
type DefaultChangelogGenerator struct{}
30+
type DefaultChangelogGenerator struct {
31+
prettifyOutput bool
32+
}
3133

3234
func (g *DefaultChangelogGenerator) Init(m map[string]string) error {
35+
prettifyOutput := false
36+
37+
prettifyConfig := m["prettify"]
38+
39+
if prettifyConfig == "true" {
40+
prettifyOutput = true
41+
}
42+
43+
g.prettifyOutput = prettifyOutput
44+
3345
return nil
3446
}
3547

@@ -41,7 +53,7 @@ func (g *DefaultChangelogGenerator) Version() string {
4153
return CGVERSION
4254
}
4355

44-
func (*DefaultChangelogGenerator) Generate(changelogConfig *generator.ChangelogGeneratorConfig) string {
56+
func (g *DefaultChangelogGenerator) Generate(changelogConfig *generator.ChangelogGeneratorConfig) string {
4557
ret := fmt.Sprintf("## %s (%s)\n\n", changelogConfig.NewVersion, time.Now().UTC().Format("2006-01-02"))
4658
clTypes := NewChangelogTypes()
4759
for _, commit := range changelogConfig.Commits {
@@ -62,7 +74,11 @@ func (*DefaultChangelogGenerator) Generate(changelogConfig *generator.ChangelogG
6274
if ct.Content == "" {
6375
continue
6476
}
65-
ret += fmt.Sprintf("#### %s\n\n%s\n", ct.Text, ct.Content)
77+
prettifyPrefix := ""
78+
if g.prettifyOutput {
79+
prettifyPrefix = ct.Emoji
80+
}
81+
ret += fmt.Sprintf("#### %s%s\n\n%s\n", prettifyPrefix, ct.Text, ct.Content)
6682
}
6783
return ret
6884
}

β€Žpkg/generator/changelog_types.goβ€Ž

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,61 +33,61 @@ var defaultTypes = ChangelogTypes{
3333
{
3434
Type: "%%bc%%",
3535
Text: "Breaking Changes",
36-
Emoji: "πŸ“£",
36+
Emoji: "πŸ“£ ",
3737
},
3838
{
3939
Type: "feat",
4040
Text: "Feature",
41-
Emoji: "🎁",
41+
Emoji: "🎁 ",
4242
},
4343
{
4444
Type: "fix",
4545
Text: "Bug Fixes",
46-
Emoji: "🐞",
46+
Emoji: "🐞 ",
4747
},
4848
{
4949
Type: "revert",
5050
Text: "Reverts",
51-
Emoji: "πŸ”™",
51+
Emoji: "πŸ”™ ",
5252
},
5353
{
5454
Type: "perf",
5555
Text: "Performance Improvements",
56-
Emoji: "πŸ“ˆ",
56+
Emoji: "πŸ“ˆ ",
5757
},
5858
{
5959
Type: "docs",
6060
Text: "Documentation",
61-
Emoji: "πŸ“„",
61+
Emoji: "πŸ“„ ",
6262
},
6363
{
6464
Type: "test",
6565
Text: "Tests",
66-
Emoji: "πŸ”Ž",
66+
Emoji: "πŸ”Ž ",
6767
},
6868
{
6969
Type: "refactor",
7070
Text: "Code Refactoring",
71-
Emoji: "πŸ”€",
71+
Emoji: "πŸ”€ ",
7272
},
7373
{
7474
Type: "style",
7575
Text: "Styles",
76-
Emoji: "🎨",
76+
Emoji: "🎨 ",
7777
},
7878
{
7979
Type: "chore",
8080
Text: "Chores",
81-
Emoji: "🚧",
81+
Emoji: "🚧 ",
8282
},
8383
{
8484
Type: "build",
8585
Text: "Build",
86-
Emoji: "πŸ“¦",
86+
Emoji: "πŸ“¦ ",
8787
},
8888
{
8989
Type: "ci",
9090
Text: "CI",
91-
Emoji: "πŸ”",
91+
Emoji: "πŸ” ",
9292
},
9393
}

0 commit comments

Comments
Β (0)