diff --git a/github2/commits.py b/github2/commits.py index f584c0a..db98851 100644 --- a/github2/commits.py +++ b/github2/commits.py @@ -1,3 +1,4 @@ +import pagerator from github2.core import BaseData, GithubCommand, Attribute, DateAttribute @@ -26,9 +27,23 @@ def __repr__(self): class Commits(GithubCommand): domain = "commits" - def list(self, project, branch="master", file=None): + def list(self, project, branch="master", file=None, page = None): + post_data = {} + if page is not None: + post_data['page'] = page return self.get_values("list", project, branch, file, - filter="commits", datatype=Commit) + filter="commits", datatype=Commit, + post_data=post_data) + + def iter(self, project, branch="master", file=None): + return pagerator.IterableQuery( + lambda page: self.get_values( + "list", project, branch, file, + filter="commits", datatype=Commit, + post_data=dict(page=page+1) + ), + 35 # page_size hardcoded in the GitHub + ) def show(self, project, sha): return self.get_value("show", project, sha,