diff --git a/IntegrationTest.py b/IntegrationTest.py index d4e44d7e..96c83192 100644 --- a/IntegrationTest.py +++ b/IntegrationTest.py @@ -150,6 +150,8 @@ class IntegrationTest: t2 = r.create_git_tree( [ { "path": "foo.bar", "mode": "100644", "type": "blob", "sha": b2.sha }, { "path": "old", "mode": "040000", "type": "tree", "sha": t1.sha } ] ) c2 = r.create_git_commit( "This commit was also created by PyGithub", t2.sha, [ c1.sha ] ) master.edit( c2.sha ) + tag = r.create_git_tag( "a_tag", "This tag was created by PyGithub", c2.sha, "commit" ) + r.create_git_ref( "refs/tags/a_tag", tag.sha ) self.dumpRepository( r ) def dumpUser( self, u ): diff --git a/ReferenceOfApis.md b/ReferenceOfApis.md index a2102aac..62e51812 100644 --- a/ReferenceOfApis.md +++ b/ReferenceOfApis.md @@ -196,11 +196,11 @@ API `/repos/:user/:repo/git/refs/:ref` API `/repos/:user/:repo/git/tags` ================================= -* POST: `Repository.create_git_tag( ... )`: `GitTag` (TODO SOON) +* POST: `Repository.create_git_tag( ... )`: `GitTag` API `/repos/:user/:repo/git/tags/:sha` ====================================== -* GET: `Repository.get_git_tag( sha )`: `GitTag` (TODO SOON) +* GET: `Repository.get_git_tag( sha )`: `GitTag` API `/repos/:user/:repo/git/trees` ================================== diff --git a/github/GithubObjects.py b/github/GithubObjects.py index e71d6a86..d3fc33b5 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -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 ) )