Skip to content

Commit 7399f5f

Browse files
authored
Merge pull request #9018 from sbueringer/pr-fix-release-notes
🐛 hack/release-notes: ensure relase notes tool can be used for external projects again
2 parents ddbf9cf + 94afcd4 commit 7399f5f

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

hack/tools/release/notes.go

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,18 @@ var (
6363
unknown,
6464
}
6565

66+
repo = flag.String("repository", "kubernetes-sigs/cluster-api", "The tag or commit to start from.")
67+
6668
fromTag = flag.String("from", "", "The tag or commit to start from.")
6769

6870
since = flag.String("since", "", "Include commits starting from and including this date. Accepts format: YYYY-MM-DD")
6971
until = flag.String("until", "", "Include commits up to and including this date. Accepts format: YYYY-MM-DD")
7072
numWorkers = flag.Int("workers", 10, "Number of concurrent routines to process PR entries. If running into GitHub rate limiting, use 1.")
7173

74+
prefixAreaLabel = flag.Bool("prefix-area-label", true, "If enabled, will prefix the area label.")
75+
76+
addKubernetesVersionSupport = flag.Bool("add-kubernetes-version-support", true, "If enabled, will add the Kubernetes version support header.")
77+
7278
tagRegex = regexp.MustCompile(`^\[release-[\w-\.]*\]`)
7379

7480
userFriendlyAreas = map[string]string{
@@ -154,7 +160,7 @@ func getAreaLabel(merge string) (string, error) {
154160
// Get pr id from merge commit
155161
prID := strings.Replace(strings.TrimSpace(strings.Split(merge, " ")[3]), "#", "", -1)
156162

157-
cmd := exec.Command("gh", "api", "repos/kubernetes-sigs/cluster-api/pulls/"+prID) //nolint:gosec
163+
cmd := exec.Command("gh", "api", fmt.Sprintf("repos/%s/pulls/%s", *repo, prID)) //nolint:gosec
158164

159165
out, err := cmd.CombinedOutput()
160166
if err != nil {
@@ -301,15 +307,18 @@ func run() int {
301307
}
302308
}
303309

304-
// TODO Turn this into a link (requires knowing the project name + organization)
305-
fmt.Print(`## 👌 Kubernetes version support
310+
if *addKubernetesVersionSupport {
311+
// TODO Turn this into a link (requires knowing the project name + organization)
312+
fmt.Print(`## 👌 Kubernetes version support
306313
307314
- Management Cluster: v1.**X**.x -> v1.**X**.x
308315
- Workload Cluster: v1.**X**.x -> v1.**X**.x
309316
310317
[More information about version support can be found here](https://cluster-api.sigs.k8s.io/reference/versions.html)
311318
312319
`)
320+
}
321+
313322
fmt.Printf("## Changes since %v\n---\n", commitRange)
314323

315324
fmt.Printf("## :chart_with_upwards_trend: Overview\n")
@@ -411,9 +420,14 @@ func generateReleaseNoteEntry(c *commit) (*releaseNoteEntry, error) {
411420
entry := &releaseNoteEntry{}
412421
entry.title = trimTitle(c.body)
413422
var fork string
414-
area, err := getAreaLabel(c.merge)
415-
if err != nil {
416-
return nil, err
423+
424+
var area string
425+
if *prefixAreaLabel {
426+
var err error
427+
area, err = getAreaLabel(c.merge)
428+
if err != nil {
429+
return nil, err
430+
}
417431
}
418432

419433
switch {
@@ -458,7 +472,13 @@ func generateReleaseNoteEntry(c *commit) (*releaseNoteEntry, error) {
458472
if entry.title == "" {
459473
return entry, nil
460474
}
461-
entry.title = fmt.Sprintf("- %s: %s", area, entry.title)
475+
476+
if *prefixAreaLabel {
477+
entry.title = fmt.Sprintf("- %s: %s", area, entry.title)
478+
} else {
479+
entry.title = fmt.Sprintf("- %s", entry.title)
480+
}
481+
462482
_, _ = fmt.Sscanf(c.merge, "Merge pull request %s from %s", &entry.prNumber, &fork)
463483
entry.title = formatMerge(entry.title, entry.prNumber)
464484

0 commit comments

Comments
 (0)