diff --git a/IntegrationTest.py b/IntegrationTest.py index fa9f0642..485c501d 100644 --- a/IntegrationTest.py +++ b/IntegrationTest.py @@ -166,7 +166,16 @@ 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 sys.stdout.flush() IntegrationTest().main() + + + +# Writes (to repository) +# ====================== + +# m = PyGithub.get_git_ref( "heads/master" ) +# m.edit( sha = m.object.sha ) \ No newline at end of file diff --git a/ReferenceOfApis.md b/ReferenceOfApis.md index 20c38da9..78cc1991 100644 --- a/ReferenceOfApis.md +++ b/ReferenceOfApis.md @@ -191,7 +191,7 @@ API `/repos/:user/:repo/git/refs` API `/repos/:user/:repo/git/refs/:ref` ====================================== -* GET: `Repository.get_git_ref( ref )`: `GitRef` (TODO SOON) +* GET: `Repository.get_git_ref( ref )`: `GitRef` * PATCH: `GitRef.edit( ... )` API `/repos/:user/:repo/git/tags` diff --git a/github/GithubObjects.py b/github/GithubObjects.py index 923feee2..d52a4d03 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -59,9 +59,11 @@ NamedUser._addAttributePolicy( ListAttribute( "orgs", Organization, ListGetable( GitRef = GithubObject( "GitRef", + BaseUrl( lambda obj: obj._repo._baseUrl + "/git/refs/" + obj.ref ), BasicAttributes( "ref", "url", - "object", ### @todo Structure + "object", ### @todo Structure, + "_repo", ### Ugly hack ), Editable( [ "sha" ], [ "force" ] ), ) @@ -85,6 +87,7 @@ Repository = GithubObject( ListAttribute( "watchers", NamedUser, ListGetable( [], [] ) ), Editable( [ "name" ], [ "description", "homepage", "public", "has_issues", "has_wiki", "has_downloads" ] ), ListOfObjects( "git/refs", GitRef, creatable = True, singularName = "git_ref" ), + ObjectGetter( "git_ref", GitRef, lambda repo, ref: { "_repo": repo, "ref": ref } ), ) Repository._addAttributePolicy( ComplexAttribute( "parent", Repository ) ) Repository._addAttributePolicy( ComplexAttribute( "source", Repository ) )