Repository.create_git_tag and .get_git_tag

This commit is contained in:
Vincent Jacques
2012-02-23 19:33:45 +00:00
parent cfccd0fddd
commit 3cbf5c9a90
3 changed files with 20 additions and 2 deletions
+16
View File
@@ -103,6 +103,18 @@ GitBlob = GithubObject(
),
)
GitTag = GithubObject(
"GitTag",
BaseUrl( lambda obj: obj._repo._baseUrl + "/git/tags/" + obj.sha ),
BasicAttributes(
"tag", "sha", "url",
"message",
"tagger", ### @todo Structure
"object", ### @todo Structure
"_repo", ### Ugly hack
),
)
__modifyAttributesForGitObjects = lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj }.iteritems() ) )
Repository = GithubObject(
"Repository",
@@ -139,6 +151,10 @@ Repository = GithubObject(
ElementGetable( "git_blob", lambda repo, sha: { "_repo": repo, "sha": sha } ),
ElementCreatable( "git_blob", [ "content", "encoding" ], [], __modifyAttributesForGitObjects )
),
ListAttribute( "git/tags", GitTag,
ElementGetable( "git_tag", lambda repo, sha: { "_repo": repo, "sha": sha } ),
ElementCreatable( "git_tag", [ "tag", "message", "object", "type" ], [ "tagger" ], __modifyAttributesForGitObjects )
),
)
Repository._addAttributePolicy( ComplexAttribute( "parent", Repository ) )
Repository._addAttributePolicy( ComplexAttribute( "source", Repository ) )