Beispiel #1
0
 def _useAttributes( self, attributes ):
     if "author" in attributes: # pragma no branch
         assert attributes[ "author" ] is None or isinstance( attributes[ "author" ], dict ), attributes[ "author" ]
         self._author = None if attributes[ "author" ] is None else GitAuthor.GitAuthor( self._requester, attributes[ "author" ], 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 GitAuthor.GitAuthor( self._requester, attributes[ "committer" ], completed = False )
     if "message" in attributes: # pragma no branch
         assert attributes[ "message" ] is None or isinstance( attributes[ "message" ], ( str, unicode ) ), attributes[ "message" ]
         self._message = attributes[ "message" ]
     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 )
             for element in attributes[ "parents" ]
         ]
     if "sha" in attributes: # pragma no branch
         assert attributes[ "sha" ] is None or isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ]
         self._sha = attributes[ "sha" ]
     if "tree" in attributes: # pragma no branch
         assert attributes[ "tree" ] is None or isinstance( attributes[ "tree" ], dict ), attributes[ "tree" ]
         self._tree = None if attributes[ "tree" ] is None else GitTree.GitTree( self._requester, attributes[ "tree" ], completed = False )
     if "url" in attributes: # pragma no branch
         assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
         self._url = attributes[ "url" ]
Beispiel #2
0
 def create_git_commit(self,
                       message,
                       tree,
                       parents,
                       author=GithubObject.NotSet,
                       committer=GithubObject.NotSet):
     assert isinstance(message, (str, unicode)), message
     assert isinstance(tree, GitTree.GitTree), tree
     assert all(
         isinstance(element, GitCommit.GitCommit)
         for element in parents), parents
     assert author is GithubObject.NotSet or isinstance(
         author, InputGitAuthor.InputGitAuthor), author
     assert committer is GithubObject.NotSet or isinstance(
         committer, InputGitAuthor.InputGitAuthor), committer
     post_parameters = {
         "message": message,
         "tree": tree._identity,
         "parents": [element._identity for element in parents],
     }
     if author is not GithubObject.NotSet:
         post_parameters["author"] = author._identity
     if committer is not GithubObject.NotSet:
         post_parameters["committer"] = committer._identity
     headers, data = self._requester.requestAndCheck(
         "POST", self.url + "/git/commits", None, post_parameters)
     return GitCommit.GitCommit(self._requester, data, completed=True)
Beispiel #3
0
 def _useAttributes( self, attributes ):
     if "author" in attributes: # pragma no branch
         assert attributes[ "author" ] is None or isinstance( attributes[ "author" ], dict ), attributes[ "author" ]
         self._author = None if attributes[ "author" ] is None else 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 GitCommit.GitCommit( self._requester, 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 NamedUser.NamedUser( self._requester, attributes[ "committer" ], completed = False )
     if "files" in attributes: # pragma no branch
         assert attributes[ "files" ] is None or all( isinstance( element, dict ) for element in attributes[ "files" ] ), attributes[ "files" ]
         self._files = None if attributes[ "files" ] is None else [
             File.File( self._requester, element, completed = False )
             for element in attributes[ "files" ]
         ]
     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 )
             for element in attributes[ "parents" ]
         ]
     if "sha" in attributes: # pragma no branch
         assert attributes[ "sha" ] is None or isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ]
         self._sha = attributes[ "sha" ]
     if "stats" in attributes: # pragma no branch
         assert attributes[ "stats" ] is None or isinstance( attributes[ "stats" ], dict ), attributes[ "stats" ]
         self._stats = None if attributes[ "stats" ] is None else CommitStats.CommitStats( self._requester, attributes[ "stats" ], completed = False )
     if "url" in attributes: # pragma no branch
         assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
         self._url = attributes[ "url" ]
Beispiel #4
0
 def get_git_commit(self, sha):
     assert isinstance(sha, (str, unicode)), sha
     headers, data = self._requester.requestAndCheck(
         "GET", self.url + "/git/commits/" + sha, None, None)
     return GitCommit.GitCommit(self._requester, data, completed=True)