From b42e1284ec65c123f588b882c468a7e585c6a5bc Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Wed, 30 May 2012 18:36:01 +0200 Subject: [PATCH] Structure the result of PullRequest.merge --- .../description.human_readable.json | 10 ++++- .../description.normalized.json | 35 ++++++++++++++++- doc/ReferenceOfClasses.md | 11 +++++- src/github/PullRequest.py | 2 + src/github/PullRequestMergeStatus.py | 39 +++++++++++++++++++ test/PullRequest.py | 3 ++ 6 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 src/github/PullRequestMergeStatus.py diff --git a/codegen/JsonDescriptionOfGithubApiV3/description.human_readable.json b/codegen/JsonDescriptionOfGithubApiV3/description.human_readable.json index 877394a7..ce323019 100644 --- a/codegen/JsonDescriptionOfGithubApiV3/description.human_readable.json +++ b/codegen/JsonDescriptionOfGithubApiV3/description.human_readable.json @@ -1125,6 +1125,14 @@ } ] }, + { + "name": "PullRequestMergeStatus", + "attributes": [ + { "name": "sha", "type": "string" }, + { "name": "merged", "type": "bool" }, + { "name": "message", "type": "string" } + ] + }, { "name": "PullRequest", "isCompletable": true, @@ -1223,7 +1231,7 @@ }, { "name": [ "merge" ], - "type": "void", + "type": "PullRequestMergeStatus", "group": "merging", "optionalParameters": [ { "name": "commit_message", "type": "string" } diff --git a/codegen/JsonDescriptionOfGithubApiV3/description.normalized.json b/codegen/JsonDescriptionOfGithubApiV3/description.normalized.json index 10de0e8a..b4bfe2b7 100644 --- a/codegen/JsonDescriptionOfGithubApiV3/description.normalized.json +++ b/codegen/JsonDescriptionOfGithubApiV3/description.normalized.json @@ -7085,9 +7085,9 @@ } ], "type": { - "simple": true, + "simple": false, "cardinality": "scalar", - "name": "void" + "name": "PullRequestMergeStatus" } } ] @@ -7329,6 +7329,37 @@ "name": "PullRequestFile", "methods": [] }, + { + "attributes": [ + { + "type": { + "simple": true, + "cardinality": "scalar", + "name": "bool" + }, + "name": "merged" + }, + { + "type": { + "simple": true, + "cardinality": "scalar", + "name": "string" + }, + "name": "message" + }, + { + "type": { + "simple": true, + "cardinality": "scalar", + "name": "string" + }, + "name": "sha" + } + ], + "isCompletable": false, + "name": "PullRequestMergeStatus", + "methods": [] + }, { "attributes": [ { diff --git a/doc/ReferenceOfClasses.md b/doc/ReferenceOfClasses.md index 8d53a7c9..8255ab48 100644 --- a/doc/ReferenceOfClasses.md +++ b/doc/ReferenceOfClasses.md @@ -914,7 +914,7 @@ Files Merging ------- * `is_merged()`: bool -* `merge( [commit_message] )` +* `merge( [commit_message] )`: `PullRequestMergeStatus` * `commit_message`: string Modification @@ -965,6 +965,15 @@ Attributes * `sha`: string * `status`: string +Class `PullRequestMergeStatus` +============================== + +Attributes +---------- +* `merged`: bool +* `message`: string +* `sha`: string + Class `Repository` ================== diff --git a/src/github/PullRequest.py b/src/github/PullRequest.py index 1ab7e832..ec979212 100644 --- a/src/github/PullRequest.py +++ b/src/github/PullRequest.py @@ -5,6 +5,7 @@ import PaginatedList from GithubObject import * import Commit import NamedUser +import PullRequestMergeStatus import PullRequestComment import PullRequestFile @@ -261,6 +262,7 @@ class PullRequest( object ): None, post_parameters ) + return PullRequestMergeStatus.PullRequestMergeStatus( self.__requester, data, completion = NoCompletion ) def __initAttributes( self ): self.__additions = None diff --git a/src/github/PullRequestMergeStatus.py b/src/github/PullRequestMergeStatus.py new file mode 100644 index 00000000..0a3cbd5a --- /dev/null +++ b/src/github/PullRequestMergeStatus.py @@ -0,0 +1,39 @@ +# WARNING: this file is generated automaticaly. +# Do not modify it manually, your work would be lost. + +import PaginatedList +from GithubObject import * + +class PullRequestMergeStatus( object ): + def __init__( self, requester, attributes, completion ): + self.__requester = requester + self.__initAttributes() + self.__useAttributes( attributes ) + + @property + def merged( self ): + return self.__merged + + @property + def message( self ): + return self.__message + + @property + def sha( self ): + return self.__sha + + def __initAttributes( self ): + self.__merged = None + self.__message = None + self.__sha = None + + def __useAttributes( self, attributes ): + if "merged" in attributes and attributes[ "merged" ] is not None: # pragma no branch + assert isinstance( attributes[ "merged" ], bool ), attributes[ "merged" ] + self.__merged = attributes[ "merged" ] + if "message" in attributes and attributes[ "message" ] is not None: # pragma no branch + assert isinstance( attributes[ "message" ], ( str, unicode ) ), attributes[ "message" ] + self.__message = attributes[ "message" ] + if "sha" in attributes and attributes[ "sha" ] is not None: # pragma no branch + assert isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ] + self.__sha = attributes[ "sha" ] diff --git a/test/PullRequest.py b/test/PullRequest.py index 7eebab42..fb61a6d5 100644 --- a/test/PullRequest.py +++ b/test/PullRequest.py @@ -58,6 +58,9 @@ class PullRequest( Framework.TestCase ): def testMerge( self ): self.assertFalse( self.pull.is_merged() ) status = self.pull.merge() + self.assertEqual( status.sha, "688208b1a5a074871d0e9376119556897439697d" ) + self.assertEqual( status.merged, True ) + self.assertEqual( status.message, "Pull Request successfully merged" ) self.assertTrue( self.pull.is_merged() ) def testMergeWithCommitMessage( self ):