forked from ask/python-github2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommits.py
More file actions
46 lines (36 loc) · 1.75 KB
/
commits.py
File metadata and controls
46 lines (36 loc) · 1.75 KB
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
37
38
39
40
41
42
43
44
45
46
from github2.core import BaseData, GithubCommand, Attribute, DateAttribute
class Commit(BaseData):
message = Attribute("Commit message.")
parents = Attribute("List of parents for this commit.")
url = Attribute("Canonical URL for this commit.")
author = Attribute("Author metadata (dict with name/email.)")
id = Attribute("Commit ID.")
committed_date = DateAttribute("Date committed.", format="commit")
authored_date = DateAttribute("Date authored.", format="commit")
tree = Attribute("Tree SHA for this commit.")
committer = Attribute("Comitter metadata (dict with name/email.)")
added = Attribute("(If present) Datastructure representing what's been "
"added since last commit.")
removed = Attribute("(if present) Datastructure representing what's been "
"removed since last commit.")
modified = Attribute("(If present) Datastructure representing what's "
"been modified since last commit.")
def __repr__(self):
return "<Commit: %s %s>" % (self.id, self.message[:64])
class Commits(GithubCommand):
domain = "commits"
def list(self, project, branch="master", file=None):
"""List commits on a project
:param str project: project name
:param str branch: branch name
:param str file: optional file filter
"""
return self.get_values("list", project, branch, file,
filter="commits", datatype=Commit)
def show(self, project, sha):
"""Get a specific commit
:param str project: project name
:param str sha: commit id
"""
return self.get_value("show", project, sha,
filter="commit", datatype=Commit)