PullRequest.is_merged and PullRequest.merge

This commit is contained in:
Vincent Jacques
2012-03-12 22:08:22 +01:00
parent 0d3b3ffd1e
commit 366ca58ca0
3 changed files with 16 additions and 3 deletions
+7
View File
@@ -481,6 +481,13 @@ class IntegrationTest:
k.delete()
self.printList( "Keys", u.get_keys(), lambda k: k.title )
def testMergePullRequest( self ):
r = self.g.get_user().get_repo( "TestPyGithub" )
p = r.get_pull( 26 )
assert not p.is_merged()
p.merge()
assert p.is_merged()
def testNamedUserDetails( self ):
u = self.g.get_user( "jacquev6" )
print u.login, "(" + u.name + ") is from", u.location
+2 -2
View File
@@ -343,8 +343,8 @@ API `/repos/:user/:repo/pulls/:id/files`
API `/repos/:user/:repo/pulls/:id/merge`
========================================
* GET: (TODO)
* PUT: (TODO)
* GET: `PullRequest.is_merged`
* PUT: `PullRequest.merge`
API `/repos/:user/:repo/pulls/comments/:id`
===========================================
+7 -1
View File
@@ -423,6 +423,10 @@ PullRequestComment = GithubObject(
Deletable(),
)
def __pullRequestIsMerged( r ):
return r._github._statusRequest( "GET", r._baseUrl + "/merge", None, None ) == 204
def __mergePullRequest( r, **data ):
r._github._statusRequest( "PUT", r._baseUrl + "/merge", None, data )
PullRequest = GithubObject(
"PullRequest",
BaseUrl( lambda obj: obj._repo._baseUrl + "/pulls/" + str( obj.number ) ),
@@ -447,6 +451,8 @@ PullRequest = GithubObject(
ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingReferedRepo ),
ElementCreatable( [ "body", "commit_id", "path", "position" ], [], __modifyAttributesForObjectsReferingReferedRepo ),
),
MethodFromCallable( "is_merged", [], [], __pullRequestIsMerged, SimpleTypePolicy( "bool" ) ),
MethodFromCallable( "merge", [], [ "commit_message" ], __mergePullRequest, SimpleTypePolicy( None ) ),
)
RepositoryKey = GithubObject(
@@ -588,7 +594,7 @@ Repository._addAttributePolicy( SeveralAttributePolicies( [
),
ExternalListOfObjects( "pulls", "pull", PullRequest,
ListGetable( [], [ "state" ], __modifyAttributesForObjectsReferingRepo ),
ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingRepo ),
ElementGetable( [ "number" ], [], __modifyAttributesForObjectsReferingRepo ),
ElementCreatable( [ "title", "body", "base", "head" ], [], __modifyAttributesForObjectsReferingRepo ),
),
] ) )