@@ -434,6 +434,15 @@ type releaseNoteEntry struct {
434
434
prNumber string
435
435
}
436
436
437
+ func modifyEntryTitle (title string , prefixes []string ) string {
438
+ entryWithoutTag := title
439
+ for _ , prefix := range prefixes {
440
+ entryWithoutTag = strings .TrimLeft (strings .TrimPrefix (entryWithoutTag , prefix ), " " )
441
+ }
442
+
443
+ return strings .ToUpper (string (entryWithoutTag [0 ])) + entryWithoutTag [1 :]
444
+ }
445
+
437
446
// generateReleaseNoteEntry processes a commit into a PR line item for the release notes.
438
447
func generateReleaseNoteEntry (c * commit ) (* releaseNoteEntry , error ) {
439
448
entry := & releaseNoteEntry {}
@@ -452,27 +461,22 @@ func generateReleaseNoteEntry(c *commit) (*releaseNoteEntry, error) {
452
461
switch {
453
462
case strings .HasPrefix (entry .title , ":sparkles:" ), strings .HasPrefix (entry .title , "✨" ):
454
463
entry .section = features
455
- entry .title = strings .TrimPrefix (entry .title , ":sparkles:" )
456
- entry .title = strings .TrimPrefix (entry .title , "✨" )
464
+ entry .title = modifyEntryTitle (entry .title , []string {":sparkles:" , "✨" })
457
465
case strings .HasPrefix (entry .title , ":bug:" ), strings .HasPrefix (entry .title , "🐛" ):
458
466
entry .section = bugs
459
- entry .title = strings .TrimPrefix (entry .title , ":bug:" )
460
- entry .title = strings .TrimPrefix (entry .title , "🐛" )
467
+ entry .title = modifyEntryTitle (entry .title , []string {":bug:" , "🐛" })
461
468
case strings .HasPrefix (entry .title , ":book:" ), strings .HasPrefix (entry .title , "📖" ):
462
469
entry .section = documentation
463
- entry .title = strings .TrimPrefix (entry .title , ":book:" )
464
- entry .title = strings .TrimPrefix (entry .title , "📖" )
470
+ entry .title = modifyEntryTitle (entry .title , []string {":book:" , "📖" })
465
471
if strings .Contains (entry .title , "CAEP" ) || strings .Contains (entry .title , "proposal" ) {
466
472
entry .section = proposals
467
473
}
468
474
case strings .HasPrefix (entry .title , ":seedling:" ), strings .HasPrefix (entry .title , "🌱" ):
469
475
entry .section = other
470
- entry .title = strings .TrimPrefix (entry .title , ":seedling:" )
471
- entry .title = strings .TrimPrefix (entry .title , "🌱" )
476
+ entry .title = modifyEntryTitle (entry .title , []string {":seedling:" , "🌱" })
472
477
case strings .HasPrefix (entry .title , ":warning:" ), strings .HasPrefix (entry .title , "⚠️" ):
473
478
entry .section = warning
474
- entry .title = strings .TrimPrefix (entry .title , ":warning:" )
475
- entry .title = strings .TrimPrefix (entry .title , "⚠️" )
479
+ entry .title = modifyEntryTitle (entry .title , []string {":warning:" , "⚠️" })
476
480
default :
477
481
entry .section = unknown
478
482
}
0 commit comments