Skip to content

Commit

Permalink
Merge pull request #63 from hellofresh/respect-amount-in-list-realeases
Browse files Browse the repository at this point in the history
Respect `amount` when listing releases
  • Loading branch information
bosunski authored Oct 25, 2024
2 parents 19802a3 + a99af1d commit a47c9b3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions github.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type (
HasNextPage githubv4.Boolean
}
Nodes []ghRelease
} `graphql:"releases(first: $limit, after: $releaseCursor, orderBy: {field:CREATED_AT, direction: DESC})"`
} `graphql:"releases(first: 10, after: $releaseCursor, orderBy: {field:CREATED_AT, direction: DESC})"`
} `graphql:"repository(owner: $repositoryOwner, name: $repositoryName)"`
}
)
Expand Down Expand Up @@ -129,7 +129,6 @@ func (g *GithubLocator) ListReleases(ctx context.Context, amount int) (_ []Relea
"repositoryOwner": githubv4.String(g.owner),
"repositoryName": githubv4.String(g.repo),
"releaseCursor": (*githubv4.String)(nil), // Null after argument to get first page.
"limit": githubv4.Int(amount),
}

var query queryRepoReleases
Expand Down Expand Up @@ -169,7 +168,8 @@ func (g *GithubLocator) ListReleases(ctx context.Context, amount int) (_ []Relea
}
}

if query.Repository.Releases.PageInfo.HasNextPage {
// If we do not have enough releases, we will continue to fetch the next page
if len(releases) < amount && query.Repository.Releases.PageInfo.HasNextPage {
variables["releaseCursor"] = githubv4.NewString(query.Repository.Releases.PageInfo.EndCursor)
continue
}
Expand Down

0 comments on commit a47c9b3

Please sign in to comment.