Skip to content

Commit 3ea7155

Browse files
authored
Merge pull request #9337 from g-gaston/minor-imrpovements-release-notes
🌱 Improve release notes formatting
2 parents 36cbd5b + 645bff9 commit 3ea7155

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

hack/tools/release/notes.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ func run() int {
352352

353353
switch key {
354354
case documentation:
355+
sort.Strings(mergeslice)
355356
if len(mergeslice) == 1 {
356357
fmt.Printf(
357358
":book: Additionally, there has been 1 contribution to our documentation and book. (%s) \n\n",
@@ -435,14 +436,14 @@ type releaseNoteEntry struct {
435436
prNumber string
436437
}
437438

438-
// modifyEntryTitle removes the specified prefixes from the title.
439-
func modifyEntryTitle(title string, prefixes []string) string {
439+
// removePrefixes removes the specified prefixes from the title.
440+
func removePrefixes(title string, prefixes []string) string {
440441
entryWithoutTag := title
441442
for _, prefix := range prefixes {
442443
entryWithoutTag = strings.TrimLeft(strings.TrimPrefix(entryWithoutTag, prefix), " ")
443444
}
444445

445-
return strings.ToUpper(string(entryWithoutTag[0])) + entryWithoutTag[1:]
446+
return entryWithoutTag
446447
}
447448

448449
// trimAreaFromTitle removes the prefixed area from title to avoid duplication.
@@ -455,6 +456,10 @@ func trimAreaFromTitle(title, area string) string {
455456
return titleWithoutArea
456457
}
457458

459+
func capitalize(str string) string {
460+
return strings.ToUpper(string(str[0])) + str[1:]
461+
}
462+
458463
// generateReleaseNoteEntry processes a commit into a PR line item for the release notes.
459464
func generateReleaseNoteEntry(c *commit) (*releaseNoteEntry, error) {
460465
entry := &releaseNoteEntry{}
@@ -476,22 +481,22 @@ func generateReleaseNoteEntry(c *commit) (*releaseNoteEntry, error) {
476481
switch {
477482
case strings.HasPrefix(entry.title, ":sparkles:"), strings.HasPrefix(entry.title, "✨"):
478483
entry.section = features
479-
entry.title = modifyEntryTitle(entry.title, []string{":sparkles:", "✨"})
484+
entry.title = removePrefixes(entry.title, []string{":sparkles:", "✨"})
480485
case strings.HasPrefix(entry.title, ":bug:"), strings.HasPrefix(entry.title, "🐛"):
481486
entry.section = bugs
482-
entry.title = modifyEntryTitle(entry.title, []string{":bug:", "🐛"})
487+
entry.title = removePrefixes(entry.title, []string{":bug:", "🐛"})
483488
case strings.HasPrefix(entry.title, ":book:"), strings.HasPrefix(entry.title, "📖"):
484489
entry.section = documentation
485-
entry.title = modifyEntryTitle(entry.title, []string{":book:", "📖"})
490+
entry.title = removePrefixes(entry.title, []string{":book:", "📖"})
486491
if strings.Contains(entry.title, "CAEP") || strings.Contains(entry.title, "proposal") {
487492
entry.section = proposals
488493
}
489494
case strings.HasPrefix(entry.title, ":seedling:"), strings.HasPrefix(entry.title, "🌱"):
490495
entry.section = other
491-
entry.title = modifyEntryTitle(entry.title, []string{":seedling:", "🌱"})
496+
entry.title = removePrefixes(entry.title, []string{":seedling:", "🌱"})
492497
case strings.HasPrefix(entry.title, ":warning:"), strings.HasPrefix(entry.title, "⚠️"):
493498
entry.section = warning
494-
entry.title = modifyEntryTitle(entry.title, []string{":warning:", "⚠️"})
499+
entry.title = removePrefixes(entry.title, []string{":warning:", "⚠️"})
495500
default:
496501
entry.section = unknown
497502
}
@@ -513,8 +518,10 @@ func generateReleaseNoteEntry(c *commit) (*releaseNoteEntry, error) {
513518

514519
if *prefixAreaLabel {
515520
entry.title = trimAreaFromTitle(entry.title, area)
521+
entry.title = capitalize(entry.title)
516522
entry.title = fmt.Sprintf("- %s: %s", area, entry.title)
517523
} else {
524+
entry.title = capitalize(entry.title)
518525
entry.title = fmt.Sprintf("- %s", entry.title)
519526
}
520527

0 commit comments

Comments
 (0)