mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 10:51:14 +00:00
PullRequest.is_merged and PullRequest.merge
This commit is contained in:
@@ -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
@@ -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`
|
||||
===========================================
|
||||
|
||||
@@ -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 ),
|
||||
),
|
||||
] ) )
|
||||
|
||||
Reference in New Issue
Block a user