diff options
author | 2012-03-04 18:27:50 +0100 | |
---|---|---|
committer | 2012-03-04 18:27:50 +0100 | |
commit | b9ad335335f9562d5cf033783b41fe40dd6efc03 (patch) | |
tree | b7d381b753eef33db0d71a1777720806e80ade03 /pygithub3/services/repos/commits.py | |
parent | Refactor result. Now it's a package (diff) | |
download | python-github3-b9ad335335f9562d5cf033783b41fe40dd6efc03.tar.xz python-github3-b9ad335335f9562d5cf033783b41fe40dd6efc03.zip |
Get repository's commits supported with new result
Diffstat (limited to 'pygithub3/services/repos/commits.py')
-rw-r--r-- | pygithub3/services/repos/commits.py | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/pygithub3/services/repos/commits.py b/pygithub3/services/repos/commits.py index fd29fc0..4ba1ff1 100644 --- a/pygithub3/services/repos/commits.py +++ b/pygithub3/services/repos/commits.py @@ -12,10 +12,35 @@ class Commits(Service, MimeTypeMixin): This service support :ref:`mimetypes-section` configuration """ - #TODO: Pagination structure differs from usual - #def list(self, user=None, repo=None, sha='', path=''): - #request = self.make_request('repos.commits.list', user=user, repo=repo) - #return self._get_result(request, sha=sha, path=path) + def list(self, user=None, repo=None, sha=None, path=None): + """ Get repository's commits + + :param str user: Username + :param str repo: Repository + :param str sha: Sha or branch to start listing commits from + :param str path: Only commits containing this file path will be returned + :returns: A :doc:`result` + + .. note:: + Remember :ref:`config precedence` + + .. warning:: + Usually a repository has thousand of commits, so be careful when + consume the result. You should filter with ``sha`` or directly + clone the repository + + :: + + commits_service.list(user='octocat', repo='oct_repo') + commits_service.list(user='octocat', repo='oct_repo', sha='dev') + commits_service.list(user='django', repo='django', sha='master', + path='django/db/utils.py') + """ + request = self.make_request('repos.commits.list', user=user, repo=repo) + params = {} + params.update(sha and {'sha': sha} or {}) + params.update(path and {'path': path} or {}) + return self._get_normal_result(request, **params) def get(self, sha, user=None, repo=None): """ Get a single commit |