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

Add missing arguments to Repository.edit #844

Merged
merged 1 commit into from
Jul 15, 2018
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
18 changes: 17 additions & 1 deletion github/Repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,17 +1194,21 @@ def delete(self):
self.url
)

def edit(self, name=None, description=github.GithubObject.NotSet, homepage=github.GithubObject.NotSet, private=github.GithubObject.NotSet, has_issues=github.GithubObject.NotSet, has_wiki=github.GithubObject.NotSet, has_downloads=github.GithubObject.NotSet, default_branch=github.GithubObject.NotSet, archived=github.GithubObject.NotSet):
def edit(self, name=None, description=github.GithubObject.NotSet, homepage=github.GithubObject.NotSet, private=github.GithubObject.NotSet, has_issues=github.GithubObject.NotSet, has_projects=github.GithubObject.NotSet, has_wiki=github.GithubObject.NotSet, has_downloads=github.GithubObject.NotSet, default_branch=github.GithubObject.NotSet, allow_squash_merge=github.GithubObject.NotSet, allow_merge_commit=github.GithubObject.NotSet, allow_rebase_merge=github.GithubObject.NotSet, archived=github.GithubObject.NotSet):
"""
:calls: `PATCH /repos/:owner/:repo <http://developer.github.com/v3/repos>`_
:param name: string
:param description: string
:param homepage: string
:param private: bool
:param has_issues: bool
:param has_projects: bool
:param has_wiki: bool
:param has_downloads: bool
:param default_branch: string
:param allow_squash_merge: bool
:param allow_merge_commit: bool
:param allow_rebase_merge: bool
:param archived: bool. Unarchiving repositories is currently not supported through API (https://developer.github.com/v3/repos/#edit)
:rtype: None
"""
Expand All @@ -1215,9 +1219,13 @@ def edit(self, name=None, description=github.GithubObject.NotSet, homepage=githu
assert homepage is github.GithubObject.NotSet or isinstance(homepage, (str, unicode)), homepage
assert private is github.GithubObject.NotSet or isinstance(private, bool), private
assert has_issues is github.GithubObject.NotSet or isinstance(has_issues, bool), has_issues
assert has_projects is github.GithubObject.NotSet or isinstance(has_projects, bool), has_projects
assert has_wiki is github.GithubObject.NotSet or isinstance(has_wiki, bool), has_wiki
assert has_downloads is github.GithubObject.NotSet or isinstance(has_downloads, bool), has_downloads
assert default_branch is github.GithubObject.NotSet or isinstance(default_branch, (str, unicode)), default_branch
assert allow_squash_merge is github.GithubObject.NotSet or (isinstance(allow_squash_merge, bool) and allow_squash_merge is True), allow_squash_merge
assert allow_merge_commit is github.GithubObject.NotSet or (isinstance(allow_merge_commit, bool) and allow_merge_commit is True), allow_merge_commit
assert allow_rebase_merge is github.GithubObject.NotSet or (isinstance(allow_rebase_merge, bool) and allow_rebase_merge is True), allow_rebase_merge
assert archived is github.GithubObject.NotSet or (isinstance(archived, bool) and archived is True), archived
post_parameters = {
"name": name,
Expand All @@ -1230,12 +1238,20 @@ def edit(self, name=None, description=github.GithubObject.NotSet, homepage=githu
post_parameters["private"] = private
if has_issues is not github.GithubObject.NotSet:
post_parameters["has_issues"] = has_issues
if has_projects is not github.GithubObject.NotSet:
post_parameters["has_projects"] = has_projects
if has_wiki is not github.GithubObject.NotSet:
post_parameters["has_wiki"] = has_wiki
if has_downloads is not github.GithubObject.NotSet:
post_parameters["has_downloads"] = has_downloads
if default_branch is not github.GithubObject.NotSet:
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_merge_commit is not github.GithubObject.NotSet:
post_parameters["allow_merge_commit"] = allow_merge_commit
if allow_rebase_merge is not github.GithubObject.NotSet:
post_parameters["allow_rebase_merge"] = allow_rebase_merge
if archived is not github.GithubObject.NotSet:
post_parameters["archived"] = archived
headers, data = self._requester.requestJsonAndCheck(
Expand Down
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_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}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually editing the request/response pair is error prone and ugly, but it is necessitated by the fact that self.repo in the test points to a repository nobody else has the correct rights to, so whenever one needs to modify one of the existing tests there's no way to just re-record the exchange.

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"}
{"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}

https
PATCH
Expand Down
3 changes: 2 additions & 1 deletion github/tests/Repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# Copyright 2018 Shinichi TAMURA <shnch.tmr@gmail.com> #
# Copyright 2018 Victor Granic <vmg@boreal321.com> #
# Copyright 2018 sfdye <tsfdye@gmail.com> #
# Copyright 2018 Jacopo Notarstefano <jacopo.notarstefano@gmail.com> #
# #
# This file is part of PyGithub. #
# http://pygithub.readthedocs.io/ #
Expand Down Expand Up @@ -184,7 +185,7 @@ def testEditWithoutArguments(self):
self.repo.edit("PyGithub")

def testEditWithAllArguments(self):
self.repo.edit("PyGithub", "Description edited by PyGithub", "http://vincent-jacques.net/PyGithub", private=True, has_issues=True, has_wiki=False, has_downloads=True)
self.repo.edit("PyGithub", "Description edited by PyGithub", "http://vincent-jacques.net/PyGithub", private=True, has_issues=True, has_projects=False, has_wiki=False, has_downloads=True, allow_squash_merge=True, allow_merge_commit=True, allow_rebase_merge=True)
self.assertEqual(self.repo.description, "Description edited by PyGithub")
self.repo.edit("PyGithub", "Python library implementing the full Github API v3")
self.assertEqual(self.repo.description, "Python library implementing the full Github API v3")
Expand Down