Skip to content

Commit 382bcc1

Browse files
Merge #13
13: fix: Duplicate pull request numbers r=AaronFriel a=AaronFriel Co-authored-by: Aaron Friel <[email protected]>
2 parents 81a7a56 + f1c2a83 commit 382bcc1

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
changes:
2+
- type: fix
3+
description: Fixes rendering the same pull request number multiple times.
4+
prs: [13, 13, 13, 13]

cmd/render.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ func extractChangelog(config *changelog.Config, dir string, filterSinceCommit st
145145
if filterSinceCommit != "" && (len(output) == 0 || len(revlist) == 0) {
146146
return nil
147147
}
148+
149+
pullRequests := map[int]struct{}{}
150+
148151
for _, v := range revlist {
149152
prs, _, err := client.PullRequests.ListPullRequestsWithCommit(context.TODO(), owner, repo, v, &github.PullRequestListOptions{})
150153
if err != nil {
@@ -155,10 +158,24 @@ func extractChangelog(config *changelog.Config, dir string, filterSinceCommit st
155158
if filterOpenPrNumber != 0 && pr.GetState() == "open" && pr.GetNumber() != filterOpenPrNumber {
156159
continue
157160
}
158-
for _, c := range entry.Entries {
159-
c.GitHubMeta.PullRequestNumbers = append(c.GitHubMeta.PullRequestNumbers, pr.GetNumber())
161+
pullRequests[pr.GetNumber()] = struct{}{}
162+
}
163+
}
164+
165+
for _, c := range entry.Entries {
166+
var prs []int
167+
for _, num := range c.GitHubMeta.PullRequestNumbers {
168+
if _, has := pullRequests[num]; has {
169+
// skip, the shared map has this entry already
170+
} else {
171+
prs = append(prs, num)
160172
}
161173
}
174+
175+
for num := range pullRequests {
176+
prs = append(prs, num)
177+
}
178+
c.GitHubMeta.PullRequestNumbers = prs
162179
}
163180

164181
fullChangelog = fullChangelog.Merge(entry)

0 commit comments

Comments
 (0)