mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Milestones
This commit is contained in:
@@ -143,6 +143,8 @@ class IntegrationTest:
|
||||
def doSomeWritesToRepository( self ):
|
||||
u = self.g.get_user()
|
||||
r = u.create_repo( name = "TestPyGithub", description = "Created by PyGithub", has_wiki = False )
|
||||
|
||||
# Git objects
|
||||
b1 = r.create_git_blob( "This blob was created by PyGithub", encoding = "latin1" )
|
||||
t1 = r.create_git_tree( [ { "path": "foo.bar", "mode": "100644", "type": "blob", "sha": b1.sha } ] )
|
||||
c1 = r.create_git_commit( "This commit was created by PyGithub", t1.sha, [] )
|
||||
@@ -153,6 +155,13 @@ class IntegrationTest:
|
||||
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 )
|
||||
|
||||
# Issues and milestones
|
||||
m = r.create_milestone( title = "This milestone was created by PyGithub" )
|
||||
m.edit( title = m.title, description = "And the description was modified by PyGithub as well" )
|
||||
m = r.create_milestone( title = "This milestone was also created by PyGithub" )
|
||||
m.delete()
|
||||
|
||||
self.dumpRepository( r )
|
||||
|
||||
def dumpUser( self, u ):
|
||||
@@ -203,6 +212,8 @@ class IntegrationTest:
|
||||
if blob.encoding == "base64":
|
||||
print base64.b64decode( blob.content ),
|
||||
print
|
||||
print " Milestones:", ", ".join( m.title + " (created by " + m.creator.login + ")" for m in r.get_milestones() )
|
||||
print " Closed milestones:", ", ".join( m.title for m in r.get_milestones( state = "closed" ) )
|
||||
print
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
+7
-7
@@ -305,16 +305,16 @@ API `/repos/:user/:repo/languages`
|
||||
|
||||
API `/repos/:user/:repo/milestones`
|
||||
===================================
|
||||
* GET: (TODO SOON)
|
||||
* POST: (TODO SOON)
|
||||
* GET: `Repository.get_milestones( ... )`: list of `Milestone`
|
||||
* POST: `Repository.create_milestone( ... )`: `Milestone`
|
||||
|
||||
API `/repos/:user/:repo/milestones/:id`
|
||||
API `/repos/:user/:repo/milestones/:number`
|
||||
=======================================
|
||||
* GET: (TODO SOON)
|
||||
* PATCH: (TODO SOON)
|
||||
* DELETE: (TODO SOON)
|
||||
* GET: `Repository.get_milestone( number )`: `Milestone`
|
||||
* PATCH: `Milestone.edit( ... )`
|
||||
* DELETE: `Milestone.delete()`
|
||||
|
||||
API `/repos/:user/:repo/milestones/:id/labels`
|
||||
API `/repos/:user/:repo/milestones/:number/labels`
|
||||
==============================================
|
||||
* GET: (TODO SOON)
|
||||
|
||||
|
||||
@@ -137,6 +137,18 @@ Teams
|
||||
-----
|
||||
* `get_teams()`: list of `Team`
|
||||
|
||||
Issues and milestones
|
||||
---------------------
|
||||
* `get_milestones( ... )`: list of `Milestone`: see [API](http://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository) for parameters
|
||||
* `create_milestone( ... )`: `Milestone`: see [API](http://developer.github.com/v3/issues/milestones/#create-a-milestone) for parameters
|
||||
* `get_milestone( number )`: `Milestone`
|
||||
|
||||
Class `Milestone`
|
||||
================
|
||||
* Attributes: see [API](http://developer.github.com/v3/issues/milestones/#get-a-single-milestone)
|
||||
* `edit( ... )`: see [API](http://developer.github.com/v3/issues/milestones/#update-a-milestone) for parameters
|
||||
* `delete()`
|
||||
|
||||
Class `Team`
|
||||
============
|
||||
* Attributes: see [API](http://developer.github.com/v3/orgs/teams/#get-team)
|
||||
|
||||
+25
-7
@@ -115,7 +115,20 @@ GitTag = GithubObject(
|
||||
),
|
||||
)
|
||||
|
||||
__modifyAttributesForGitObjects = lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj }.iteritems() ) )
|
||||
Milestone = GithubObject(
|
||||
"Milestone",
|
||||
BaseUrl( lambda obj: obj._repo._baseUrl + "/milestones/" + str( obj.number ) ),
|
||||
BasicAttributes(
|
||||
"url", "number", "state", "title", "description", "open_issues",
|
||||
"closed_issues", "created_at", "due_on",
|
||||
"_repo", ### Ugly hack
|
||||
),
|
||||
ComplexAttribute( "creator", NamedUser ),
|
||||
Editable( [ "title" ], [ "state", "description", "due_on" ] ),
|
||||
Deletable(),
|
||||
)
|
||||
|
||||
__modifyAttributesForObjectsReferingRepo = lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj }.iteritems() ) )
|
||||
Repository = GithubObject(
|
||||
"Repository",
|
||||
BaseUrl( lambda obj: "/repos/" + obj.owner.login + "/" + obj.name ),
|
||||
@@ -135,26 +148,31 @@ Repository = GithubObject(
|
||||
ListAttribute( "watchers", NamedUser, ListGetable( [], [] ) ),
|
||||
Editable( [ "name" ], [ "description", "homepage", "public", "has_issues", "has_wiki", "has_downloads" ] ),
|
||||
ListAttribute( "git/refs", GitRef,
|
||||
ListGetable( [], [], __modifyAttributesForGitObjects ),
|
||||
ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ),
|
||||
ElementGetable( "git_ref", lambda repo, ref: { "_repo": repo, "ref": ref } ),
|
||||
ElementCreatable( "git_ref", [ "ref", "sha" ], [], __modifyAttributesForGitObjects )
|
||||
ElementCreatable( "git_ref", [ "ref", "sha" ], [], __modifyAttributesForObjectsReferingRepo )
|
||||
),
|
||||
ListAttribute( "git/commits", GitCommit,
|
||||
ElementGetable( "git_commit", lambda repo, sha: { "_repo": repo, "sha": sha } ),
|
||||
ElementCreatable( "git_commit", [ "message", "tree", "parents" ], [ "author", "commiter" ], __modifyAttributesForGitObjects )
|
||||
ElementCreatable( "git_commit", [ "message", "tree", "parents" ], [ "author", "commiter" ], __modifyAttributesForObjectsReferingRepo )
|
||||
),
|
||||
ListAttribute( "git/trees", GitTree,
|
||||
ElementGetable( "git_tree", lambda repo, sha: { "_repo": repo, "sha": sha } ),
|
||||
ElementCreatable( "git_tree", [ "tree" ], [], __modifyAttributesForGitObjects )
|
||||
ElementCreatable( "git_tree", [ "tree" ], [], __modifyAttributesForObjectsReferingRepo )
|
||||
),
|
||||
ListAttribute( "git/blobs", GitBlob,
|
||||
ElementGetable( "git_blob", lambda repo, sha: { "_repo": repo, "sha": sha } ),
|
||||
ElementCreatable( "git_blob", [ "content", "encoding" ], [], __modifyAttributesForGitObjects )
|
||||
ElementCreatable( "git_blob", [ "content", "encoding" ], [], __modifyAttributesForObjectsReferingRepo )
|
||||
),
|
||||
ListAttribute( "git/tags", GitTag,
|
||||
ElementGetable( "git_tag", lambda repo, sha: { "_repo": repo, "sha": sha } ),
|
||||
ElementCreatable( "git_tag", [ "tag", "message", "object", "type" ], [ "tagger" ], __modifyAttributesForGitObjects )
|
||||
ElementCreatable( "git_tag", [ "tag", "message", "object", "type" ], [ "tagger" ], __modifyAttributesForObjectsReferingRepo )
|
||||
),
|
||||
ListAttribute( "milestones", Milestone,
|
||||
ListGetable( [], [ "state", "sort", "direction" ] ),
|
||||
ElementGetable( "milestone", lambda repo, number: { "_repo": repo, "number": number } ),
|
||||
ElementCreatable( "milestone", [ "title" ], [ "state", "description", "due_on" ], __modifyAttributesForObjectsReferingRepo )
|
||||
)
|
||||
)
|
||||
Repository._addAttributePolicy( ComplexAttribute( "parent", Repository ) )
|
||||
Repository._addAttributePolicy( ComplexAttribute( "source", Repository ) )
|
||||
|
||||
Reference in New Issue
Block a user