From 8c4b9465e66afebb2c8ee55673a16b43113fd8db Mon Sep 17 00:00:00 2001 From: BradChengIRESS <49461141+BradChengIRESS@users.noreply.github.com> Date: Fri, 19 May 2023 05:33:18 +1000 Subject: [PATCH] Add allow_auto_merge support to Repository (#2477) Co-authored-by: Glenn McDonald --- github/Repository.py | 19 +++++++++++++++++++ .../Repository.testEditWithAllArguments.txt | 4 ++-- tests/Repository.py | 2 ++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/github/Repository.py b/github/Repository.py index f36fe1df..73f9903b 100644 --- a/github/Repository.py +++ b/github/Repository.py @@ -159,6 +159,14 @@ class Repository(github.GithubObject.CompletableGithubObject): def __repr__(self): return self.get__repr__({"full_name": self._full_name.value}) + @property + def allow_auto_merge(self): + """ + :type: bool + """ + self._completeIfNotSet(self._allow_auto_merge) + return self._allow_auto_merge.value + @property def allow_forking(self): """ @@ -1569,6 +1577,7 @@ class Repository(github.GithubObject.CompletableGithubObject): has_wiki=github.GithubObject.NotSet, has_downloads=github.GithubObject.NotSet, default_branch=github.GithubObject.NotSet, + allow_auto_merge=github.GithubObject.NotSet, allow_forking=github.GithubObject.NotSet, allow_squash_merge=github.GithubObject.NotSet, allow_merge_commit=github.GithubObject.NotSet, @@ -1624,6 +1633,9 @@ class Repository(github.GithubObject.CompletableGithubObject): assert default_branch is github.GithubObject.NotSet or isinstance( default_branch, str ), default_branch + assert allow_auto_merge is github.GithubObject.NotSet or isinstance( + allow_auto_merge, bool + ), allow_auto_merge assert allow_forking is github.GithubObject.NotSet or isinstance( allow_forking, bool ), allow_forking @@ -1666,6 +1678,8 @@ class Repository(github.GithubObject.CompletableGithubObject): post_parameters["default_branch"] = default_branch if allow_squash_merge is not github.GithubObject.NotSet: post_parameters["allow_squash_merge"] = allow_squash_merge + if allow_auto_merge is not github.GithubObject.NotSet: + post_parameters["allow_auto_merge"] = allow_auto_merge if allow_forking is not github.GithubObject.NotSet: post_parameters["allow_forking"] = allow_forking if allow_merge_commit is not github.GithubObject.NotSet: @@ -3835,6 +3849,7 @@ class Repository(github.GithubObject.CompletableGithubObject): ) def _initAttributes(self): + self._allow_auto_merge = github.GithubObject.NotSet self._allow_forking = github.GithubObject.NotSet self._allow_merge_commit = github.GithubObject.NotSet self._allow_rebase_merge = github.GithubObject.NotSet @@ -3923,6 +3938,10 @@ class Repository(github.GithubObject.CompletableGithubObject): self._watchers_count = github.GithubObject.NotSet def _useAttributes(self, attributes): + if "allow_auto_merge" in attributes: # pragma no branch + self._allow_auto_merge = self._makeBoolAttribute( + attributes["allow_auto_merge"] + ) if "allow_forking" in attributes: # pragma no branch self._allow_forking = self._makeBoolAttribute(attributes["allow_forking"]) if "allow_merge_commit" in attributes: # pragma no branch diff --git a/tests/ReplayData/Repository.testEditWithAllArguments.txt b/tests/ReplayData/Repository.testEditWithAllArguments.txt index 57eec6aa..fdf5bf2e 100644 --- a/tests/ReplayData/Repository.testEditWithAllArguments.txt +++ b/tests/ReplayData/Repository.testEditWithAllArguments.txt @@ -4,10 +4,10 @@ api.github.com None /repos/jacquev6/PyGithub {'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} -{"has_wiki": false, "name": "PyGithub", "has_downloads": true, "has_issues": true, "homepage": "http://vincent-jacques.net/PyGithub", "private": true, "description": "Description edited by PyGithub", "has_projects": false, "allow_update_branch": true, "allow_forking": true, "allow_squash_merge": true, "allow_merge_commit": true, "allow_rebase_merge": true, "delete_branch_on_merge": true} +{"has_wiki": false, "name": "PyGithub", "has_downloads": true, "has_issues": true, "homepage": "http://vincent-jacques.net/PyGithub", "private": true, "description": "Description edited by PyGithub", "has_projects": false, "allow_auto_merge": true, "allow_update_branch": true, "allow_forking": true, "allow_squash_merge": true, "allow_merge_commit": true, "allow_rebase_merge": true, "delete_branch_on_merge": true} 200 [('status', '200 OK'), ('x-ratelimit-remaining', '4953'), ('content-length', '1109'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"749313ec2d171323deb61f9f4c85e84f"'), ('date', 'Sat, 26 May 2012 11:22:13 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"clone_url":"https://github.com/jacquev6/PyGithub.git","has_downloads":true,"watchers":13,"updated_at":"2012-05-26T11:22:13Z","permissions":{"pull":true,"admin":true,"push":true},"homepage":"http://vincent-jacques.net/PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub","has_wiki":false,"has_issues":true,"fork":false,"forks":2,"size":412,"git_url":"git://github.com/jacquev6/PyGithub.git","private":false,"open_issues":16,"mirror_url":null,"svn_url":"https://github.com/jacquev6/PyGithub","owner":{"url":"https://api.github.com/users/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"name":"PyGithub","language":"Python","description":"Description edited by PyGithub","ssh_url":"git@github.com:jacquev6/PyGithub.git","pushed_at":"2012-05-26T10:01:38Z","created_at":"2012-02-25T12:53:47Z","id":3544490,"html_url":"https://github.com/jacquev6/PyGithub","full_name":"jacquev6/PyGithub", "has_projects": false, "allow_update_branch": true, "allow_forking": true, "allow_squash_merge": true, "allow_merge_commit": true, "allow_rebase_merge": true, "delete_branch_on_merge": true} +{"clone_url":"https://github.com/jacquev6/PyGithub.git","has_downloads":true,"watchers":13,"updated_at":"2012-05-26T11:22:13Z","permissions":{"pull":true,"admin":true,"push":true},"homepage":"http://vincent-jacques.net/PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub","has_wiki":false,"has_issues":true,"fork":false,"forks":2,"size":412,"git_url":"git://github.com/jacquev6/PyGithub.git","private":false,"open_issues":16,"mirror_url":null,"svn_url":"https://github.com/jacquev6/PyGithub","owner":{"url":"https://api.github.com/users/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"name":"PyGithub","language":"Python","description":"Description edited by PyGithub","ssh_url":"git@github.com:jacquev6/PyGithub.git","pushed_at":"2012-05-26T10:01:38Z","created_at":"2012-02-25T12:53:47Z","id":3544490,"html_url":"https://github.com/jacquev6/PyGithub","full_name":"jacquev6/PyGithub", "has_projects": false, "allow_auto_merge": true, "allow_update_branch": true, "allow_forking": true, "allow_squash_merge": true, "allow_merge_commit": true, "allow_rebase_merge": true, "delete_branch_on_merge": true} https PATCH diff --git a/tests/Repository.py b/tests/Repository.py index 1f999c1d..34f9eede 100644 --- a/tests/Repository.py +++ b/tests/Repository.py @@ -134,6 +134,7 @@ class Repository(Framework.TestCase): has_projects=False, has_wiki=False, has_downloads=True, + allow_auto_merge=True, allow_forking=True, allow_update_branch=True, allow_squash_merge=True, @@ -152,6 +153,7 @@ class Repository(Framework.TestCase): self.assertFalse(self.repo.has_projects) self.assertFalse(self.repo.has_wiki) self.assertTrue(self.repo.has_downloads) + self.assertTrue(self.repo.allow_auto_merge) self.assertTrue(self.repo.allow_forking) self.assertTrue(self.repo.allow_squash_merge) self.assertTrue(self.repo.allow_merge_commit)