Repository.get_git_tree (and .create_git_tree, not tested)

This commit is contained in:
Vincent Jacques
2012-02-23 19:17:24 +00:00
parent 93c0fd842f
commit ce5eb2c022
3 changed files with 24 additions and 3 deletions
+4 -1
View File
@@ -167,7 +167,10 @@ class IntegrationTest:
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() )
masterCommitSha = r.get_git_ref( "refs/heads/master" ).object[ "sha" ]
print " Master:", masterCommitSha, r.get_git_commit( masterCommitSha ).message
masterCommit = r.get_git_commit( masterCommitSha )
masterTreeSha = masterCommit.tree[ "sha" ]
masterTree = r.get_git_tree( masterTreeSha )
print " Master:", masterCommitSha, masterCommit.message, ", ".join( element[ "path" ] + " (" + element[ "type" ] + ")" for element in masterTree.tree )
print
sys.stdout.flush()
+6 -2
View File
@@ -204,11 +204,15 @@ API `/repos/:user/:repo/git/tags/:sha`
API `/repos/:user/:repo/git/trees`
==================================
* POST: `Repository.create_git_tree( ... )`: `GitTree` (TODO SOON)
* POST: `Repository.create_git_tree( ... )`: `GitTree`
API `/repos/:user/:repo/git/trees?base_tree=`
=============================================
* POST: `GitTree.create_update( ... )`: `GitTree` (TODO SOON)
API `/repos/:user/:repo/git/trees/:sha`
=======================================
* GET: `Repository.get_git_tree( sha )`: `GitTree` (TODO SOON)
* GET: `Repository.get_git_tree( sha )`: `GitTree`
API `/repos/:user/:repo/git/trees/:sha?recursive=1`
===================================================
+14
View File
@@ -83,6 +83,16 @@ GitCommit = GithubObject(
),
)
GitTree = GithubObject(
"GitTree",
BaseUrl( lambda obj: obj._repo._baseUrl + "/git/trees/" + obj.sha ),
BasicAttributes(
"sha", "url",
"tree", ### @todo Structure
"_repo", ### Ugly hack
),
)
__modifyAttributesForGitObjects = lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj }.iteritems() ) )
Repository = GithubObject(
"Repository",
@@ -111,6 +121,10 @@ Repository = GithubObject(
ElementGetable( "git_commit", lambda repo, sha: { "_repo": repo, "sha": sha } ),
ElementCreatable( "git_commit", [ "message", "tree", "parents" ], [ "author", "commiter" ], __modifyAttributesForGitObjects )
),
ListAttribute( "git/trees", GitTree,
ElementGetable( "git_tree", lambda repo, sha: { "_repo": repo, "sha": sha } ),
ElementCreatable( "git_tree", [ "tree" ], [], __modifyAttributesForGitObjects )
),
)
Repository._addAttributePolicy( ComplexAttribute( "parent", Repository ) )
Repository._addAttributePolicy( ComplexAttribute( "source", Repository ) )