Skip to content

Commit

Permalink
fix: Get only latest releases for component bumps release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloarodas committed Nov 22, 2023
1 parent ceb386a commit 3842938
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
18 changes: 6 additions & 12 deletions pkg/cargo/bump.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,14 @@ func fetchReleasesFromRepo(ctx context.Context, repoService RepositoryReleaseLis
var result []*github.RepositoryRelease

ops := github.ListOptions{}
for {
releases, _, _ := repoService.ListReleases(ctx, owner, repo, &ops)
if len(releases) == 0 {
break
}
releases, _, _ := repoService.ListReleases(ctx, owner, repo, &ops)

for _, rel := range releases {
rv, err := semver.NewVersion(strings.TrimPrefix(rel.GetTagName(), "v"))
if err != nil || rv.LessThan(from) || rv.Equal(from) || rv.GreaterThan(to) {
continue
}
result = append(result, rel)
for _, rel := range releases {
rv, err := semver.NewVersion(strings.TrimPrefix(rel.GetTagName(), "v"))
if err != nil || rv.LessThan(from) || rv.Equal(from) || rv.GreaterThan(to) {
continue
}
ops.Page++
result = append(result, rel)
}

return result
Expand Down
6 changes: 1 addition & 5 deletions pkg/cargo/bump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ func TestInternal_addReleaseNotes(t *testing.T) {
{Body: strPtr("labeled"), TagName: strPtr("1.0.1")},
{Body: strPtr("chopped"), TagName: strPtr("0.2.2")},
{Body: strPtr("preserved"), TagName: strPtr("1.0.0")},
}, githubResponse(t, 200), nil
case 1:
ltsCallCount++
return []*github.RepositoryRelease{
{Body: strPtr("cleaned"), TagName: strPtr("0.2.1")},
{Body: strPtr("ripe"), TagName: strPtr("0.1.3")},
{Body: strPtr("unripe"), TagName: strPtr("0.1.2")},
Expand Down Expand Up @@ -151,7 +147,7 @@ func TestInternal_addReleaseNotes(t *testing.T) {
please.Expect(err).NotTo(HaveOccurred())
please.Expect(result).To(HaveLen(2))

please.Expect(ltsCallCount).To(Equal(3))
please.Expect(ltsCallCount).To(Equal(1))

please.Expect(result[0].ReleaseNotes()).To(Equal("served\nplated\nstored\nlabeled\npreserved\nchopped\ncleaned"))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/notes/notes_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func Test_fetch(t *testing.T) {
please.Expect(historicVersion.CallCount()).To(Equal(1))
_, historicVersionHashArg, _ := historicVersion.ArgsForCall(0)
please.Expect(historicVersionHashArg).To(Equal(finalHash))
please.Expect(fakeReleaseService.ListReleasesCallCount()).To(Equal(2))
please.Expect(fakeReleaseService.ListReleasesCallCount()).To(Equal(1))
please.Expect(fakeIssuesService.GetCallCount()).To(Equal(2))

_, orgName, repoName, n := fakeIssuesService.GetArgsForCall(0)
Expand Down

0 comments on commit 3842938

Please sign in to comment.