Skip to content

Commit

Permalink
Address review comments: rename types and add doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
g-gaston committed Jun 13, 2023
1 parent 1892cfd commit 24cb6b7
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions hack/tools/release/notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,16 @@ func run() int {
}
}

results := make(chan processCommitResult)
jobs := make(chan *commit)
results := make(chan releaseNoteEntryResult)
commitCh := make(chan *commit)
var wg sync.WaitGroup

wg.Add(*numWorkers)
for i := 0; i < *numWorkers; i++ {
go func() {
for commit := range jobs {
processed := processCommitResult{}
processed.prEntry, processed.err = generateNotesPREntry(commit)
for commit := range commitCh {
processed := releaseNoteEntryResult{}
processed.prEntry, processed.err = generateReleaseNoteEntry(commit)
results <- processed
}
wg.Done()
Expand All @@ -243,9 +243,9 @@ func run() int {

go func() {
for _, c := range commits {
jobs <- c
commitCh <- c
}
close(jobs)
close(commitCh)
}()

go func() {
Expand Down Expand Up @@ -345,19 +345,23 @@ func commandExists(cmd string) bool {
return err == nil
}

type processCommitResult struct {
prEntry *prEntry
// releaseNoteEntryResult is the result of processing a PR to create a release note item.
// Used to aggregate the line item and error when processing concurrently.
type releaseNoteEntryResult struct {
prEntry *releaseNoteEntry
err error
}

type prEntry struct {
// releaseNoteEntry represents a line item in the release notes.
type releaseNoteEntry struct {
title string
section string
prNumber string
}

func generateNotesPREntry(c *commit) (*prEntry, error) {
entry := &prEntry{}
// generateReleaseNoteEntry processes a commit into a PR line item for the release notes.
func generateReleaseNoteEntry(c *commit) (*releaseNoteEntry, error) {
entry := &releaseNoteEntry{}
entry.title = trimTitle(c.body)
var fork string
prefix, err := getAreaLabel(c.merge)
Expand Down

0 comments on commit 24cb6b7

Please sign in to comment.