repo.compare_commits doesn't use pagination
amaccormack-lumira opened this issue · 4 comments
amaccormack-lumira commented
Since 2021, github API supports pagination on Comparison results: https://github.blog/changelog/2021-03-22-compare-rest-api-now-supports-pagination/
but this package still gives a list of 250, not an iterator that would use pagination, meaning diffs are incomplete.
sigmavirus24 commented
Would be happy to review a PR that fixed this
amaccormack-lumira commented
Yep, got a solution working on my machine, but never submitted a PR to anyone else's project before! Give me a minute and I'll try.
basically, changing comparison.py:
def _update_attributes(self, compare):
self._api = compare["url"]
self.ahead_by = compare["ahead_by"]
self.base_commit = commit.ShortCommit(compare["base_commit"], self)
self.behind_by = compare["behind_by"]
self.commits = compare["commits"]
self.total_commits = compare["total_commits"]
if self.commits:
if self.total_commits>len(self.commits):
self.commits=self._iter(-1, self._api, commit.ShortCommit, list_key="commits")
else:
self.commits = [
commit.ShortCommit(com, self) for com in self.commits
]
sigmavirus24 commented
Just always do _iter. Inconsistent return types will bite users and confuse them.
amaccormack-lumira commented
Fair enough, although by default github API returns 250 items with the original call, so trying to save some bandwidth