8000 add per_page parameter to commits method · pythonthings/github3.py@26f9a81 · GitHub
[go: up one dir, main page]

Skip to content

Commit 26f9a81

Browse files
committed
add per_page parameter to commits method
1 parent 96726db commit 26f9a81

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

AUTHORS.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,5 @@ Contributors
124124
- Christophe Lecointe (@christophelec)
125125

126126
- Abhijeet Kasurde (@akasurde)
127+
128+
- Alexander Koshelev <daevaorn@gmail.com>

github3/repos/repo.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def commit_comment(self, comment_id):
520520
return self._instance_or_null(RepoComment, json)
521521

522522
def commits(self, sha=None, path=None, author=None, number=-1, etag=None,
523-
since=None, until=None):
523+
since=None, until=None, per_page=None):
524524
r"""Iterate over commits in this repository.
525525
526526
:param str sha: (optional), sha or branch to start listing commits
@@ -541,13 +541,15 @@ def commits(self, sha=None, path=None, author=None, number=-1, etag=None,
541541
be returned. This can be a ``datetime`` or an ``ISO8601`` formatted
542542
date string.
543543
:type until: datetime or string
544+
:param int per_page: (optional), commits listing page size
544545
545546
:returns: generator of
546547
:class:`RepoCommit <github3.repos.commit.RepoCommit>`\ s
547548
"""
548549
params = {'sha': sha, 'path': path, 'author': author,
549550
'since': timestamp_parameter(since),
550-
'until': timestamp_parameter(until)}
551+
'until': timestamp_parameter(until),
552+
'per_page': per_page}
551553

552554
self._remove_none(params)
553555
url = self._build_url('commits', base_url=self._api)

tests/unit/test_repos_repo.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,18 @@ def test_commits_since_until_datetime(self):
10871087
headers={}
10881088
)
10891089

1090+
def test_commits_per_page(self):
1091+
"""Test the ability to specify page size for commits listing."""
1092+
1093+
i = self.instance.commits(per_page=10)
1094+
self.get_next(i)
1095+
1096+
self.session.get.assert_called_once_with(
1097+
url_for('commits'),
1098+
params={'per_page': 10},
1099+
headers={}
1100+
)
1101+
10901102
def test_commits_sha_path(self):
10911103
"""Test the ability to filter commits by branch and path."""
10921104
i = self.instance.commits(sha='branch', path='tests/')

0 commit comments

Comments
 (0)
0