Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add allow_forking to Repository #2380

Merged
merged 3 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
rev: v5.10.1
hooks:
- id: isort
- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
Expand Down
17 changes: 17 additions & 0 deletions github/Repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ class Repository(github.GithubObject.CompletableGithubObject):
def __repr__(self):
return self.get__repr__({"full_name": self._full_name.value})

@property
def allow_forking(self):
"""
:type: bool
"""
self._completeIfNotSet(self._allow_forking)
return self._allow_forking.value

@property
def allow_merge_commit(self):
"""
Expand Down Expand Up @@ -1552,6 +1560,7 @@ def edit(
has_wiki=github.GithubObject.NotSet,
has_downloads=github.GithubObject.NotSet,
default_branch=github.GithubObject.NotSet,
allow_forking=github.GithubObject.NotSet,
allow_squash_merge=github.GithubObject.NotSet,
allow_merge_commit=github.GithubObject.NotSet,
allow_rebase_merge=github.GithubObject.NotSet,
Expand Down Expand Up @@ -1603,6 +1612,9 @@ def edit(
assert default_branch is github.GithubObject.NotSet or isinstance(
default_branch, str
), default_branch
assert allow_forking is github.GithubObject.NotSet or isinstance(
allow_forking, bool
), allow_forking
assert allow_squash_merge is github.GithubObject.NotSet or isinstance(
allow_squash_merge, bool
), allow_squash_merge
Expand Down Expand Up @@ -1639,6 +1651,8 @@ def edit(
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_forking is not github.GithubObject.NotSet:
post_parameters["allow_forking"] = allow_forking
if allow_merge_commit is not github.GithubObject.NotSet:
post_parameters["allow_merge_commit"] = allow_merge_commit
if allow_rebase_merge is not github.GithubObject.NotSet:
Expand Down Expand Up @@ -3787,6 +3801,7 @@ def get_codescan_alerts(self):
)

def _initAttributes(self):
self._allow_forking = github.GithubObject.NotSet
self._allow_merge_commit = github.GithubObject.NotSet
self._allow_rebase_merge = github.GithubObject.NotSet
self._allow_squash_merge = github.GithubObject.NotSet
Expand Down Expand Up @@ -3873,6 +3888,8 @@ def _initAttributes(self):
self._watchers_count = github.GithubObject.NotSet

def _useAttributes(self, attributes):
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
self._allow_merge_commit = self._makeBoolAttribute(
attributes["allow_merge_commit"]
Expand Down
4 changes: 2 additions & 2 deletions tests/ReplayData/Repository.testEditWithAllArguments.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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_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_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_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_forking": true, "allow_squash_merge": true, "allow_merge_commit": true, "allow_rebase_merge": true, "delete_branch_on_merge": true}

https
PATCH
Expand Down
2 changes: 2 additions & 0 deletions tests/Repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def testEditWithAllArguments(self):
has_projects=False,
has_wiki=False,
has_downloads=True,
allow_forking=True,
allow_squash_merge=True,
allow_merge_commit=True,
allow_rebase_merge=True,
Expand All @@ -149,6 +150,7 @@ def testEditWithAllArguments(self):
self.assertFalse(self.repo.has_projects)
self.assertFalse(self.repo.has_wiki)
self.assertTrue(self.repo.has_downloads)
self.assertTrue(self.repo.allow_forking)
self.assertTrue(self.repo.allow_squash_merge)
self.assertTrue(self.repo.allow_merge_commit)
self.assertTrue(self.repo.allow_rebase_merge)
Expand Down