Skip to content

Commit

Permalink
Improve multiple areas PRs with user friendly subs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
g-gaston committed Aug 7, 2023
1 parent 2061cab commit 333b213
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions hack/tools/release/notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand All @@ -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
}
}

Expand Down Expand Up @@ -371,6 +371,7 @@ func run() int {
str2 := strings.ToLower(mergeslice[j])
return str1 < str2
})

for _, merge := range mergeslice {
fmt.Println(merge)
}
Expand Down

0 comments on commit 333b213

Please sign in to comment.