Update Commit.py and GitCommit.py

This commit is contained in:
AKFish
2013-08-21 15:26:05 +08:00
parent 83c6495ec5
commit ed32e78da1
7 changed files with 18 additions and 29 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ class Branch(github.GithubObject.NonCompletableGithubObject):
def _useAttributes(self, attributes):
if "commit" in attributes: # pragma no branch
assert attributes["commit"] is None or isinstance(attributes["commit"], dict), attributes["commit"]
self._commit = None if attributes["commit"] is None else github.Commit.Commit(self._requester, attributes["commit"], completed=False)
self._commit = None if attributes["commit"] is None else github.Commit.Commit(self._requester, self._headers, attributes["commit"], completed=False)
if "name" in attributes: # pragma no branch
assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"]
self._name = attributes["name"]
+2 -5
View File
@@ -39,9 +39,6 @@ class Commit(github.GithubObject.CompletableGithubObject):
"""
This class represents Commits. The reference can be found here http://developer.github.com/v3/git/commits/
"""
def __init__(self, requester, attributes, completed):
# Adapte for __init__ change, remove later
github.GithubObject.CompletableGithubObject.__init__(self, requester, {}, attributes, completed)
@property
def author(self):
@@ -207,7 +204,7 @@ class Commit(github.GithubObject.CompletableGithubObject):
self._author = None if attributes["author"] is None else github.NamedUser.NamedUser(self._requester, attributes["author"], completed=False)
if "commit" in attributes: # pragma no branch
assert attributes["commit"] is None or isinstance(attributes["commit"], dict), attributes["commit"]
self._commit = None if attributes["commit"] is None else github.GitCommit.GitCommit(self._requester, attributes["commit"], completed=False)
self._commit = None if attributes["commit"] is None else github.GitCommit.GitCommit(self._requester, self._headers, attributes["commit"], completed=False)
if "committer" in attributes: # pragma no branch
assert attributes["committer"] is None or isinstance(attributes["committer"], dict), attributes["committer"]
self._committer = None if attributes["committer"] is None else github.NamedUser.NamedUser(self._requester, attributes["committer"], completed=False)
@@ -220,7 +217,7 @@ class Commit(github.GithubObject.CompletableGithubObject):
if "parents" in attributes: # pragma no branch
assert attributes["parents"] is None or all(isinstance(element, dict) for element in attributes["parents"]), attributes["parents"]
self._parents = None if attributes["parents"] is None else [
Commit(self._requester, element, completed=False)
Commit(self._requester, self._headers, element, completed=False)
for element in attributes["parents"]
]
if "sha" in attributes: # pragma no branch
+2 -2
View File
@@ -153,14 +153,14 @@ class Comparison(github.GithubObject.CompletableGithubObject):
self._ahead_by = attributes["ahead_by"]
if "base_commit" in attributes: # pragma no branch
assert attributes["base_commit"] is None or isinstance(attributes["base_commit"], dict), attributes["base_commit"]
self._base_commit = None if attributes["base_commit"] is None else github.Commit.Commit(self._requester, attributes["base_commit"], completed=False)
self._base_commit = None if attributes["base_commit"] is None else github.Commit.Commit(self._requester, self._headers, attributes["base_commit"], completed=False)
if "behind_by" in attributes: # pragma no branch
assert attributes["behind_by"] is None or isinstance(attributes["behind_by"], (int, long)), attributes["behind_by"]
self._behind_by = attributes["behind_by"]
if "commits" in attributes: # pragma no branch
assert attributes["commits"] is None or all(isinstance(element, dict) for element in attributes["commits"]), attributes["commits"]
self._commits = None if attributes["commits"] is None else [
github.Commit.Commit(self._requester, element, completed=False)
github.Commit.Commit(self._requester, self._headers, element, completed=False)
for element in attributes["commits"]
]
if "diff_url" in attributes: # pragma no branch
+1 -4
View File
@@ -33,9 +33,6 @@ class GitCommit(github.GithubObject.CompletableGithubObject):
"""
This class represents GitCommits as returned for example by http://developer.github.com/v3/todo
"""
def __init__(self, requester, attributes, completed):
# Adapte for __init__ change, remove later
github.GithubObject.CompletableGithubObject.__init__(self, requester, {}, attributes, completed)
@property
def author(self):
@@ -119,7 +116,7 @@ class GitCommit(github.GithubObject.CompletableGithubObject):
if "parents" in attributes: # pragma no branch
assert attributes["parents"] is None or all(isinstance(element, dict) for element in attributes["parents"]), attributes["parents"]
self._parents = None if attributes["parents"] is None else [
GitCommit(self._requester, element, completed=False)
GitCommit(self._requester, self._headers, element, completed=False)
for element in attributes["parents"]
]
if "sha" in attributes: # pragma no branch
+7 -12
View File
@@ -118,21 +118,16 @@ class PaginatedList(PaginatedListBase):
'''
Adapte for diffrent __init__ signature in refactoring, remove when done
'''
try:
try: # Try use old __init__ signature
return [
self.__contentClass(self.__requester, element, completed=False)
for element in data]
except TypeError: # must be new
return [
self.__contentClass(self.__requester, headers, element, completed=False)
for element in data]
except:
print "WTF???????????"
print self.__contentClass
try: # Try use old __init__ signature
return [
self.__contentClass(self.__requester, element, completed=False)
for element in data]
except TypeError: # must be new
return [
self.__contentClass(self.__requester, headers, element, completed=False)
for element in data]
+4 -4
View File
@@ -420,7 +420,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
None,
post_parameters
)
return github.GitCommit.GitCommit(self._requester, data, completed=True)
return github.GitCommit.GitCommit(self._requester, headers, data, completed=True)
def create_git_ref(self, ref, sha):
"""
@@ -838,7 +838,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
None,
None
)
return github.Commit.Commit(self._requester, data, completed=True)
return github.Commit.Commit(self._requester, headers, data, completed=True)
def get_commits(self, sha=github.GithubObject.NotSet, path=github.GithubObject.NotSet):
"""
@@ -1014,7 +1014,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
None,
None
)
return github.GitCommit.GitCommit(self._requester, data, completed=True)
return github.GitCommit.GitCommit(self._requester, headers, data, completed=True)
def get_git_ref(self, ref):
"""
@@ -1566,7 +1566,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
if data is None:
return None
else:
return github.Commit.Commit(self._requester, data, completed=True)
return github.Commit.Commit(self._requester, headers, data, completed=True)
def remove_from_collaborators(self, collaborator):
"""
+1 -1
View File
@@ -71,7 +71,7 @@ class Tag(github.GithubObject.NonCompletableGithubObject):
def _useAttributes(self, attributes):
if "commit" in attributes: # pragma no branch
assert attributes["commit"] is None or isinstance(attributes["commit"], dict), attributes["commit"]
self._commit = None if attributes["commit"] is None else github.Commit.Commit(self._requester, attributes["commit"], completed=False)
self._commit = None if attributes["commit"] is None else github.Commit.Commit(self._requester, self._headers, attributes["commit"], completed=False)
if "name" in attributes: # pragma no branch
assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"]
self._name = attributes["name"]