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 18, 2023
1 parent a8356e4 commit cab14a1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions hack/tools/release/notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,16 @@ 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+":"):])
}
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,6 +511,7 @@ func generateReleaseNoteEntry(c *commit) (*releaseNoteEntry, error) {
}

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

0 comments on commit cab14a1

Please sign in to comment.