|
70 | 70 | numWorkers = flag.Int("workers", 10, "Number of concurrent routines to process PR entries. If running into GitHub rate limiting, use 1.")
|
71 | 71 |
|
72 | 72 | tagRegex = regexp.MustCompile(`^\[release-[\w-\.]*\]`)
|
| 73 | + |
| 74 | + userFriendlyAreas = map[string]string{ |
| 75 | + "e2e-testing": "e2e", |
| 76 | + "provider/control-plane-kubeadm": "KCP", |
| 77 | + "provider/infrastructure-docker": "CAPD", |
| 78 | + "dependency": "Dependency", |
| 79 | + "devtools": "Devtools", |
| 80 | + "machine": "Machine", |
| 81 | + "api": "API", |
| 82 | + } |
| 83 | + |
| 84 | + releaseBackportMarker = regexp.MustCompile(`(?m)^\[release-\d\.\d\]\s*`) |
73 | 85 | )
|
74 | 86 |
|
75 | 87 | func main() {
|
@@ -113,6 +125,7 @@ const (
|
113 | 125 | missingAreaLabelPrefix = "MISSING_AREA"
|
114 | 126 | areaLabelPrefix = "area/"
|
115 | 127 | multipleAreaLabelsPrefix = "MULTIPLE_AREAS["
|
| 128 | + documentationAreaLabel = "documentation" |
116 | 129 | )
|
117 | 130 |
|
118 | 131 | type githubPullRequest struct {
|
@@ -150,7 +163,11 @@ func getAreaLabel(merge string) (string, error) {
|
150 | 163 | case 0:
|
151 | 164 | return missingAreaLabelPrefix, nil
|
152 | 165 | case 1:
|
153 |
| - return areaLabels[0], nil |
| 166 | + area := areaLabels[0] |
| 167 | + if userFriendlyArea, ok := userFriendlyAreas[area]; ok { |
| 168 | + area = userFriendlyArea |
| 169 | + } |
| 170 | + return area, nil |
154 | 171 | default:
|
155 | 172 | return multipleAreaLabelsPrefix + strings.Join(areaLabels, "|") + "]", nil
|
156 | 173 | }
|
@@ -274,10 +291,18 @@ func run() int {
|
274 | 291 | fmt.Printf("Changes since %v\n---\n", commitRange)
|
275 | 292 |
|
276 | 293 | fmt.Printf("## :chart_with_upwards_trend: Overview\n")
|
277 |
| - fmt.Printf("- %d new commits merged\n", len(commits)) |
278 |
| - fmt.Printf("- %d breaking changes :warning:\n", len(merges[warning])) |
279 |
| - fmt.Printf("- %d feature additions ✨\n", len(merges[features])) |
280 |
| - fmt.Printf("- %d bugs fixed 🐛\n", len(merges[bugs])) |
| 294 | + if count := len(commits); count > 0 { |
| 295 | + fmt.Printf("- %d new commits merged\n", count) |
| 296 | + } |
| 297 | + if count := len(merges[warning]); count > 0 { |
| 298 | + fmt.Printf("- %d breaking changes :warning:\n", count) |
| 299 | + } |
| 300 | + if count := len(merges[features]); count > 0 { |
| 301 | + fmt.Printf("- %d feature additions ✨\n", count) |
| 302 | + } |
| 303 | + if count := len(merges[bugs]); count > 0 { |
| 304 | + fmt.Printf("- %d bugs fixed 🐛\n", count) |
| 305 | + } |
281 | 306 | fmt.Println()
|
282 | 307 |
|
283 | 308 | for _, key := range outputOrder {
|
@@ -364,7 +389,7 @@ func generateReleaseNoteEntry(c *commit) (*releaseNoteEntry, error) {
|
364 | 389 | entry := &releaseNoteEntry{}
|
365 | 390 | entry.title = trimTitle(c.body)
|
366 | 391 | var fork string
|
367 |
| - prefix, err := getAreaLabel(c.merge) |
| 392 | + area, err := getAreaLabel(c.merge) |
368 | 393 | if err != nil {
|
369 | 394 | return nil, err
|
370 | 395 | }
|
@@ -397,13 +422,29 @@ func generateReleaseNoteEntry(c *commit) (*releaseNoteEntry, error) {
|
397 | 422 | entry.section = unknown
|
398 | 423 | }
|
399 | 424 |
|
| 425 | + // If the area label indicates documentation, use documentation as the section |
| 426 | + // no matter what was the emoji used. This takes into account that the area label |
| 427 | + // tends to be more accurate than the emoji (data point observed by the release team). |
| 428 | + // We handle this after the switch statement to make sure we remove all emoji prefixes. |
| 429 | + if area == documentationAreaLabel { |
| 430 | + entry.section = documentation |
| 431 | + } |
| 432 | + |
400 | 433 | entry.title = strings.TrimSpace(entry.title)
|
| 434 | + entry.title = trimReleaseBackportMarker(entry.title) |
| 435 | + |
401 | 436 | if entry.title == "" {
|
402 | 437 | return entry, nil
|
403 | 438 | }
|
404 |
| - entry.title = fmt.Sprintf("- %s: %s", prefix, entry.title) |
| 439 | + entry.title = fmt.Sprintf("- %s: %s", area, entry.title) |
405 | 440 | _, _ = fmt.Sscanf(c.merge, "Merge pull request %s from %s", &entry.prNumber, &fork)
|
406 | 441 | entry.title = formatMerge(entry.title, entry.prNumber)
|
407 | 442 |
|
408 | 443 | return entry, nil
|
409 | 444 | }
|
| 445 | + |
| 446 | +// trimReleaseBackportMarker removes the `[release-x.x]` prefix from a PR title if present. |
| 447 | +// These are mostly used for back-ported PRs in release branches. |
| 448 | +func trimReleaseBackportMarker(title string) string { |
| 449 | + return releaseBackportMarker.ReplaceAllString(title, "${1}") |
| 450 | +} |
0 commit comments