Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gitlab list MRs: return all, not just 20
Browse files Browse the repository at this point in the history
> python-gitlab==3.14.0

```
Calling a `list()` method without specifying `get_all=True` or
`iterator=True` will return a maximum of 20 items. Your query returned
20 of 87 items.
```

Signed-off-by: Tomas Tomecek <[email protected]>
TomasTomecek committed Oct 25, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 346e911 commit bb1e2ec
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ogr/services/gitlab/pull_request.py
Original file line number Diff line number Diff line change
@@ -240,10 +240,17 @@ def get_list(
status: PRStatus = PRStatus.open,
) -> list["PullRequest"]:
# Gitlab API has status 'opened', not 'open'
# f"Calling a `list()` method without specifying `get_all=True` or "
# f"`iterator=True` will return a maximum of 20 items. "
mrs = project.gitlab_repo.mergerequests.list(
state=status.name if status != PRStatus.open else "opened",
order_by="updated_at",
sort="desc",
# new gitlab syntax
get_all=True,
# gitlab 3.3 syntax
# https://github.com/python-gitlab/python-gitlab/blob/v3.3.0/gitlab/client.py#L815
all=True,
)
return [GitlabPullRequest(mr, project) for mr in mrs]

0 comments on commit bb1e2ec

Please sign in to comment.