diff --git a/IntegrationTest.py b/IntegrationTest.py index 43440a8a..4faed8c5 100644 --- a/IntegrationTest.py +++ b/IntegrationTest.py @@ -166,7 +166,7 @@ class IntegrationTest: print " Watchers:", ", ".join( u.login for u in r.get_watchers() ) print " Forks:", ", ".join( f.owner.login + "/" + f.name for f in r.get_forks() ) print " References:", ", ".join( ref.ref + " (" + ref.object[ "sha" ][ :7 ] + ")" for ref in r.get_git_refs() ) - print " Master:", r.get_git_ref( "heads/master" ).object[ "sha" ] + print " Master:", r.get_git_ref( "refs/heads/master" ).object[ "sha" ] print sys.stdout.flush() diff --git a/github/GithubObjects.py b/github/GithubObjects.py index d2321600..a6db20f2 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -70,6 +70,7 @@ GitRef = GithubObject( Editable( [ "sha" ], [ "force" ] ), ) +__modifyAttributesForGitRef = lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj }.iteritems() ) ) Repository = GithubObject( "Repository", BaseUrl( lambda obj: "/repos/" + obj.owner.login + "/" + obj.name ), @@ -88,8 +89,11 @@ 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" ], [] ), modifyAttributes = lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj }.iteritems() ) ) ), - ObjectGetter( "git_ref", GitRef, lambda repo, ref: { "_repo": repo, "ref": ref } ), + ListAttribute( "git/refs", GitRef, + ListGetable( [], [], __modifyAttributesForGitRef ), + ElementGetable( "git_ref", lambda repo, ref: { "_repo": repo, "ref": ref } ), + ElementCreatable( "git_ref", [ "ref", "sha" ], [], __modifyAttributesForGitRef ) + ) ) Repository._addAttributePolicy( ComplexAttribute( "parent", Repository ) ) Repository._addAttributePolicy( ComplexAttribute( "source", Repository ) ) diff --git a/github/ObjectCapacities/List.py b/github/ObjectCapacities/List.py index 1ec4cb0b..acc8dd9e 100644 --- a/github/ObjectCapacities/List.py +++ b/github/ObjectCapacities/List.py @@ -45,7 +45,7 @@ class ElementCreatable: def __execute( self, obj, *args, **kwds ): data = self.__argumentsChecker.check( args, kwds ) - return self.__type( obj._github, self.__modifyAttributes( obj._github._dataRequest( "POST", obj._baseUrl + "/" + self.__attributeName, None, data ) ), lazy = True ) + return self.__type( obj._github, self.__modifyAttributes( obj, obj._github._dataRequest( "POST", obj._baseUrl + "/" + self.__attributeName, None, data ) ), lazy = True ) class ListGetable: def __init__( self, mandatoryParameters, optionalParameters, modifyAttributes = lambda obj, attributes: attributes ): @@ -60,7 +60,7 @@ class ListGetable: def __execute( self, obj, *args, **kwds ): params = self.__argumentsChecker.check( args, kwds ) return [ - self.__type( obj._github, self.__modifyAttributes( attributes ), lazy = True ) + self.__type( obj._github, self.__modifyAttributes( obj, attributes ), lazy = True ) for attributes in obj._github._dataRequest( "GET", obj._baseUrl + "/" + self.__attributeName, params, None ) ]