From 333b213d82dc5f81f76614ec76a4fd0dc1d52921 Mon Sep 17 00:00:00 2001 From: Guillermo Gaston Date: Mon, 24 Jul 2023 22:21:53 +0000 Subject: [PATCH] Improve multiple areas PRs with user friendly subs This applies the same user friendly areas substitutions to the multiple areas entries that it was already applied to single area entries. As a bonus, add a case insensitive string sorting that avoids exponential string allocation. --- hack/tools/release/notes.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hack/tools/release/notes.go b/hack/tools/release/notes.go index 889b0be38dcc..fab10f357b3c 100644 --- a/hack/tools/release/notes.go +++ b/hack/tools/release/notes.go @@ -175,6 +175,10 @@ func getAreaLabel(merge string) (string, error) { var areaLabels []string for _, label := range pr.Labels { if area, ok := trimAreaLabel(label.Name); ok { + if userFriendlyArea, ok := userFriendlyAreas[area]; ok { + area = userFriendlyArea + } + areaLabels = append(areaLabels, area) } } @@ -183,13 +187,9 @@ func getAreaLabel(merge string) (string, error) { case 0: return missingAreaLabelPrefix, nil case 1: - area := areaLabels[0] - if userFriendlyArea, ok := userFriendlyAreas[area]; ok { - area = userFriendlyArea - } - return area, nil + return areaLabels[0], nil default: - return multipleAreaLabelsPrefix + strings.Join(areaLabels, "|") + "]", nil + return multipleAreaLabelsPrefix + strings.Join(areaLabels, "/") + "]", nil } } @@ -371,6 +371,7 @@ func run() int { str2 := strings.ToLower(mergeslice[j]) return str1 < str2 }) + for _, merge := range mergeslice { fmt.Println(merge) }