@@ -435,6 +435,7 @@ type releaseNoteEntry struct {
435
435
prNumber string
436
436
}
437
437
438
+ // modifyEntryTitle removes the specified prefixes from the title.
438
439
func modifyEntryTitle (title string , prefixes []string ) string {
439
440
entryWithoutTag := title
440
441
for _ , prefix := range prefixes {
@@ -444,6 +445,16 @@ func modifyEntryTitle(title string, prefixes []string) string {
444
445
return strings .ToUpper (string (entryWithoutTag [0 ])) + entryWithoutTag [1 :]
445
446
}
446
447
448
+ // trimAreaFromTitle removes the prefixed area from title to avoid duplication.
449
+ func trimAreaFromTitle (title , area string ) string {
450
+ titleWithoutArea := title
451
+ pattern := `(?i)^` + regexp .QuoteMeta (area + ":" )
452
+ re := regexp .MustCompile (pattern )
453
+ titleWithoutArea = re .ReplaceAllString (titleWithoutArea , "" )
454
+ titleWithoutArea = strings .TrimSpace (titleWithoutArea )
455
+ return titleWithoutArea
456
+ }
457
+
447
458
// generateReleaseNoteEntry processes a commit into a PR line item for the release notes.
448
459
func generateReleaseNoteEntry (c * commit ) (* releaseNoteEntry , error ) {
449
460
entry := & releaseNoteEntry {}
@@ -501,6 +512,7 @@ func generateReleaseNoteEntry(c *commit) (*releaseNoteEntry, error) {
501
512
}
502
513
503
514
if * prefixAreaLabel {
515
+ entry .title = trimAreaFromTitle (entry .title , area )
504
516
entry .title = fmt .Sprintf ("- %s: %s" , area , entry .title )
505
517
} else {
506
518
entry .title = fmt .Sprintf ("- %s" , entry .title )
0 commit comments