Skip to content

Commit

Permalink
Deduplicating area in title
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhairya-Arora01 committed Aug 15, 2023
1 parent a8356e4 commit 8049f06
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion hack/tools/release/notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,17 @@ func modifyEntryTitle(title string, prefixes []string) string {
return strings.ToUpper(string(entryWithoutTag[0])) + entryWithoutTag[1:]
}

// trimAreaFromTitle removes area from title to avoid duplication
func trimAreaFromTitle(title, area string) string {
titleWithoutArea := title
position := strings.Index(title, area+":")
if position != -1 {
titleWithoutArea = strings.TrimSpace(titleWithoutArea[position+len(area+":"):])
}
titleWithoutArea = fmt.Sprintf("- %s: %s", area, titleWithoutArea)
return titleWithoutArea
}

// generateReleaseNoteEntry processes a commit into a PR line item for the release notes.
func generateReleaseNoteEntry(c *commit) (*releaseNoteEntry, error) {
entry := &releaseNoteEntry{}
Expand Down Expand Up @@ -501,7 +512,7 @@ func generateReleaseNoteEntry(c *commit) (*releaseNoteEntry, error) {
}

if *prefixAreaLabel {
entry.title = fmt.Sprintf("- %s: %s", area, entry.title)
entry.title = trimAreaFromTitle(entry.title, area)
} else {
entry.title = fmt.Sprintf("- %s", entry.title)
}
Expand Down

0 comments on commit 8049f06

Please sign in to comment.