diff --git a/IntegrationTest.py b/IntegrationTest.py index c1a795a5..43440a8a 100644 --- a/IntegrationTest.py +++ b/IntegrationTest.py @@ -203,6 +203,6 @@ IntegrationTest().main() # To repository # ------------- -# branch = r.create_git_ref( "refs/heads/test", r.get_git_ref( "heads/master" ).object[ "sha" ] ) +# branch = r.create_git_ref( "refs/heads/test", r.get_git_ref( "refs/heads/master" ).object[ "sha" ] ) # branch.edit( "cf96b288a03daba509c0ec7e3e7384fe9e0f472d", force = True ) -# r.get_git_ref( "heads/test" ).edit( "9f868e490c79c3ec899dc450e7cb4f9b0fa9e88c", force = True ) +# r.get_git_ref( "refs/heads/test" ).edit( "9f868e490c79c3ec899dc450e7cb4f9b0fa9e88c", force = True ) diff --git a/ReferenceOfClasses.md b/ReferenceOfClasses.md index 6b7c7ee9..788a8b93 100644 --- a/ReferenceOfClasses.md +++ b/ReferenceOfClasses.md @@ -131,7 +131,7 @@ Git objects Class `GitRef` ============== * Attributes: see [API](http://developer.github.com/v3/git/refs/#get-a-reference) -* `edit( ... )`: see [API](http://developer.github.com/v3/git/refs/#update-a-reference) for parameters (TODO SOON: edit `GitRef`s returned but `get_git_refs` or `create_git_ref`) +* `edit( ... )`: see [API](http://developer.github.com/v3/git/refs/#update-a-reference) for parameters Class `GitBlob` =============== diff --git a/github/GithubObjects.py b/github/GithubObjects.py index 21880cd0..d2321600 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -1,3 +1,5 @@ +import itertools + from GithubObject import * AuthenticatedUser = GithubObject( @@ -59,7 +61,7 @@ NamedUser._addAttributePolicy( ListAttribute( "orgs", Organization, ListGetable( GitRef = GithubObject( "GitRef", - BaseUrl( lambda obj: obj._repo._baseUrl + "/git/refs/" + obj.ref ), + BaseUrl( lambda obj: obj._repo._baseUrl + "/git/" + obj.ref ), BasicAttributes( "ref", "url", "object", ### @todo Structure, @@ -86,7 +88,7 @@ Repository = GithubObject( ListAttribute( "contributors", NamedUser, ListGetable( [], [] ) ), ListAttribute( "watchers", NamedUser, ListGetable( [], [] ) ), Editable( [ "name" ], [ "description", "homepage", "public", "has_issues", "has_wiki", "has_downloads" ] ), - ListOfObjects( "git/refs", GitRef, Creatable( "git_ref", [ "ref", "sha" ], [] ) ), + ListOfObjects( "git/refs", GitRef, Creatable( "git_ref", [ "ref", "sha" ], [] ), modifyAttributes = lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj }.iteritems() ) ) ), ObjectGetter( "git_ref", GitRef, lambda repo, ref: { "_repo": repo, "ref": ref } ), ) Repository._addAttributePolicy( ComplexAttribute( "parent", Repository ) ) diff --git a/github/ObjectCapacities/List.py b/github/ObjectCapacities/List.py index a86d5da9..1ec4cb0b 100644 --- a/github/ObjectCapacities/List.py +++ b/github/ObjectCapacities/List.py @@ -33,9 +33,10 @@ class ElementHasable: return obj._github._statusRequest( "GET", obj._baseUrl + "/" + self.__attributeName + "/" + toBeQueried._identity, None, None ) == 204 class ElementCreatable: - def __init__( self, singularName, mandatoryParameters, optionalParameters ): + def __init__( self, singularName, mandatoryParameters, optionalParameters, modifyAttributes = lambda obj, attributes: attributes ): self.__argumentsChecker = ArgumentsChecker.ArgumentsChecker( mandatoryParameters, optionalParameters ) self.__createName = "create_" + singularName + self.__modifyAttributes = modifyAttributes def apply( self, list, cls ): self.__type = list.type @@ -44,11 +45,12 @@ class ElementCreatable: def __execute( self, obj, *args, **kwds ): data = self.__argumentsChecker.check( args, kwds ) - return self.__type( obj._github, obj._github._dataRequest( "POST", obj._baseUrl + "/" + self.__attributeName, None, data ), lazy = True ) + return self.__type( obj._github, self.__modifyAttributes( obj._github._dataRequest( "POST", obj._baseUrl + "/" + self.__attributeName, None, data ) ), lazy = True ) class ListGetable: - def __init__( self, mandatoryParameters, optionalParameters ): + def __init__( self, mandatoryParameters, optionalParameters, modifyAttributes = lambda obj, attributes: attributes ): self.__argumentsChecker = ArgumentsChecker.ArgumentsChecker( mandatoryParameters, optionalParameters ) + self.__modifyAttributes = modifyAttributes def apply( self, list, cls ): self.__type = list.type @@ -58,7 +60,7 @@ class ListGetable: def __execute( self, obj, *args, **kwds ): params = self.__argumentsChecker.check( args, kwds ) return [ - self.__type( obj._github, attributes, lazy = True ) + self.__type( obj._github, self.__modifyAttributes( attributes ), lazy = True ) for attributes in obj._github._dataRequest( "GET", obj._baseUrl + "/" + self.__attributeName, params, None ) ]