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
+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 ) )