Skip to content

Commit eecc038

Browse files
committed
feat: Update release notes tool to handle multiples_areas and colons
Signed-off-by: chandankumar4 <[email protected]>
1 parent eb4e38c commit eecc038

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

hack/tools/release/notes/process.go

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ import (
3131
)
3232

3333
const (
34-
missingAreaLabelPrefix = "MISSING_AREA"
35-
areaLabelPrefix = "area/"
36-
multipleAreaLabelsPrefix = "MULTIPLE_AREAS["
37-
documentationArea = "Documentation"
34+
missingAreaLabelPrefix = "MISSING_AREA"
35+
areaLabelPrefix = "area/"
36+
documentationArea = "Documentation"
3837
)
3938

4039
var (
@@ -200,11 +199,27 @@ func (g prEntriesProcessor) generateNoteEntry(p *pr) *notesEntry {
200199
}
201200

202201
entry.prNumber = fmt.Sprintf("%d", p.number)
202+
entry.title = updateTitle(entry.title)
203203
entry.title = formatPREntry(entry.title, entry.prNumber)
204204

205205
return entry
206206
}
207207

208+
// UpdateTitle updates a title by removing the multiple colons(:).
209+
func updateTitle(input string) string {
210+
// Remove the extra colons from the title
211+
colonCount := strings.Count(input, ":")
212+
if colonCount == 2 {
213+
// Find the position of the first colon
214+
firstColonIndex := strings.Index(input, ":")
215+
// Extract the part after the first colon and remove any leading spaces
216+
partAfterColon := strings.TrimSpace(input[firstColonIndex+1:])
217+
// Replace the first colon with "/"
218+
input = input[:firstColonIndex] + "/" + partAfterColon
219+
}
220+
return input
221+
}
222+
208223
// extractArea processes the PR labels to extract the area.
209224
func (g prEntriesProcessor) extractArea(pr *pr) string {
210225
var areaLabels []string
@@ -226,7 +241,7 @@ func (g prEntriesProcessor) extractArea(pr *pr) string {
226241
case 1:
227242
return areaLabels[0]
228243
default:
229-
return multipleAreaLabelsPrefix + strings.Join(areaLabels, "/") + "]"
244+
return strings.Join(areaLabels, "/")
230245
}
231246
}
232247

0 commit comments

Comments
 (0)