Skip to content

Commit 6c53e54

Browse files
IbrahimAHhussaiia
andauthored
feat: add allow_forking to Repository (PyGithub#2380)
* chore(dependency): flake8 has moved to github * feat: add allow_forking to Repository * chore: linting Co-authored-by: hussaiia <ibrahim.hussaini@cba.com.au>
1 parent 7902351 commit 6c53e54

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
rev: v5.10.1
1212
hooks:
1313
- id: isort
14-
- repo: https://gitlab.com/pycqa/flake8
14+
- repo: https://github.com/pycqa/flake8
1515
rev: 3.9.2
1616
hooks:
1717
- id: flake8

github/Repository.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ class Repository(github.GithubObject.CompletableGithubObject):
158158
def __repr__(self):
159159
return self.get__repr__({"full_name": self._full_name.value})
160160

161+
@property
162+
def allow_forking(self):
163+
"""
164+
:type: bool
165+
"""
166+
self._completeIfNotSet(self._allow_forking)
167+
return self._allow_forking.value
168+
161169
@property
162170
def allow_merge_commit(self):
163171
"""
@@ -1552,6 +1560,7 @@ def edit(
15521560
has_wiki=github.GithubObject.NotSet,
15531561
has_downloads=github.GithubObject.NotSet,
15541562
default_branch=github.GithubObject.NotSet,
1563+
allow_forking=github.GithubObject.NotSet,
15551564
allow_squash_merge=github.GithubObject.NotSet,
15561565
allow_merge_commit=github.GithubObject.NotSet,
15571566
allow_rebase_merge=github.GithubObject.NotSet,
@@ -1603,6 +1612,9 @@ def edit(
16031612
assert default_branch is github.GithubObject.NotSet or isinstance(
16041613
default_branch, str
16051614
), default_branch
1615+
assert allow_forking is github.GithubObject.NotSet or isinstance(
1616+
allow_forking, bool
1617+
), allow_forking
16061618
assert allow_squash_merge is github.GithubObject.NotSet or isinstance(
16071619
allow_squash_merge, bool
16081620
), allow_squash_merge
@@ -1639,6 +1651,8 @@ def edit(
16391651
post_parameters["default_branch"] = default_branch
16401652
if allow_squash_merge is not github.GithubObject.NotSet:
16411653
post_parameters["allow_squash_merge"] = allow_squash_merge
1654+
if allow_forking is not github.GithubObject.NotSet:
1655+
post_parameters["allow_forking"] = allow_forking
16421656
if allow_merge_commit is not github.GithubObject.NotSet:
16431657
post_parameters["allow_merge_commit"] = allow_merge_commit
16441658
if allow_rebase_merge is not github.GithubObject.NotSet:
@@ -3787,6 +3801,7 @@ def get_codescan_alerts(self):
37873801
)
37883802

37893803
def _initAttributes(self):
3804+
self._allow_forking = github.GithubObject.NotSet
37903805
self._allow_merge_commit = github.GithubObject.NotSet
37913806
self._allow_rebase_merge = github.GithubObject.NotSet
37923807
self._allow_squash_merge = github.GithubObject.NotSet
@@ -3873,6 +3888,8 @@ def _initAttributes(self):
38733888
self._watchers_count = github.GithubObject.NotSet
38743889

38753890
def _useAttributes(self, attributes):
3891+
if "allow_forking" in attributes: # pragma no branch
3892+
self._allow_forking = self._makeBoolAttribute(attributes["allow_forking"])
38763893
if "allow_merge_commit" in attributes: # pragma no branch
38773894
self._allow_merge_commit = self._makeBoolAttribute(
38783895
attributes["allow_merge_commit"]

tests/ReplayData/Repository.testEditWithAllArguments.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ api.github.com
44
None
55
/repos/jacquev6/PyGithub
66
{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
7-
{"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_squash_merge": true, "allow_merge_commit": true, "allow_rebase_merge": true, "delete_branch_on_merge": true}
7+
{"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_forking": true, "allow_squash_merge": true, "allow_merge_commit": true, "allow_rebase_merge": true, "delete_branch_on_merge": true}
88
200
99
[('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')]
10-
{"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_squash_merge": true, "allow_merge_commit": true, "allow_rebase_merge": true, "delete_branch_on_merge": true}
10+
{"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_forking": true, "allow_squash_merge": true, "allow_merge_commit": true, "allow_rebase_merge": true, "delete_branch_on_merge": true}
1111

1212
https
1313
PATCH

tests/Repository.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def testEditWithAllArguments(self):
134134
has_projects=False,
135135
has_wiki=False,
136136
has_downloads=True,
137+
allow_forking=True,
137138
allow_squash_merge=True,
138139
allow_merge_commit=True,
139140
allow_rebase_merge=True,
@@ -149,6 +150,7 @@ def testEditWithAllArguments(self):
149150
self.assertFalse(self.repo.has_projects)
150151
self.assertFalse(self.repo.has_wiki)
151152
self.assertTrue(self.repo.has_downloads)
153+
self.assertTrue(self.repo.allow_forking)
152154
self.assertTrue(self.repo.allow_squash_merge)
153155
self.assertTrue(self.repo.allow_merge_commit)
154156
self.assertTrue(self.repo.allow_rebase_merge)

0 commit comments

Comments
 (0)