mirror of
https://github.com/kennethreitz-archive/github2.git
synced 2026-06-05 23:50:18 +00:00
Added support for Commits (http://develop.github.com/p/commits.html)
This commit is contained in:
@@ -2,6 +2,7 @@ from github2.request import GithubRequest
|
||||
from github2.issues import Issues
|
||||
from github2.repositories import Repositories
|
||||
from github2.users import Users
|
||||
from github2.commits import Commits
|
||||
|
||||
class Github(object):
|
||||
|
||||
@@ -10,6 +11,7 @@ class Github(object):
|
||||
self.issues = Issues(self.request)
|
||||
self.users = Users(self.request)
|
||||
self.repos = Repositories(self.request)
|
||||
self.commits = Commits(self.request)
|
||||
|
||||
def project_for_user_repo(self, user, repo):
|
||||
return "/".join([user, repo])
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
from github2.core import BaseData, GithubCommand
|
||||
|
||||
|
||||
class Commit(BaseData):
|
||||
attributes = ("message", "parents", "url", "author", "id",
|
||||
"committed_date", "authored_date", "tree", "committer",
|
||||
"added", "removed", "modified")
|
||||
date_attributes = ("committed_date", "authored_date")
|
||||
|
||||
|
||||
class Commits(GithubCommand):
|
||||
domain = "commits"
|
||||
|
||||
def list(self, project, branch="master", file=None):
|
||||
return self.get_values("list", project, branch, file,
|
||||
filter="commits", datatype=Commit)
|
||||
|
||||
def show(self, project, sha):
|
||||
return self.get_value("show", project, sha,
|
||||
filter="commit", datatype=Commit)
|
||||
|
||||
|
||||
+3
-1
@@ -4,7 +4,7 @@ import simplejson
|
||||
from urlparse import urlparse
|
||||
from urllib import urlencode
|
||||
|
||||
URL_PREFIX = "https://github.com/api/v2/json"
|
||||
URL_PREFIX = "http://github.com/api/v2/json"
|
||||
|
||||
class GithubError(Exception):
|
||||
"""An error occured when making a request to the Github API."""
|
||||
@@ -30,9 +30,11 @@ class GithubRequest(object):
|
||||
return urlencode(post_data)
|
||||
|
||||
def get(self, *path_components):
|
||||
path_components = filter(None, path_components)
|
||||
return self.make_request("/".join(path_components))
|
||||
|
||||
def post(self, *path_components, **extra_post_data):
|
||||
path_components = filter(None, path_components)
|
||||
return self.make_request("/".join(path_components), extra_post_data)
|
||||
|
||||
def make_request(self, path, extra_post_data=None):
|
||||
|
||||
Reference in New Issue
Block a user