aboutsummaryrefslogtreecommitdiffstats
path: root/pygithub3/services/git_data/commits.py
blob: ddeed98a144301a1e1eef297fd4d18a6647063cc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

from pygithub3.services.base import Service


class Commits(Service):
    """Consume `Commits API <http://developer.github.com/v3/git/commits/>`_"""

    def get(self, sha, user=None, repo=None):
        """get a commit from the current repo

        :param str sha: SHA of the Commit that you want
        :param str user: Username
        :param str repo: Repository

        .. note::
            Remember :ref:`config precedence`
        """
        request = self.make_request('git_data.commits.get', sha=sha,
            user=user, repo=repo)
        return self._get(request)

    def create(self, data, user=None, repo=None):
        """create a commit on a repo

        :param dict data: Input. See `github commits doc`_
        :param str user: Username
        :param str repo: Repository

        .. note::
            Remember :ref:`config precedence`
        """
        request = self.make_request('git_data.commits.create', user=user,
            repo=repo, body=data)
        return self._post(request)