mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 03:11:09 +00:00
Add missing properties to Repository (#842)
Closes #784 Closes #785 First commit fixes a small bug that I observed while trying to record some new test fixtures: the stringification of the headers is not correctly printed as a list of tuples, but as an `iteritems` object, so I forced the list evaluation. Second commit adds the missing properties `allow_merge_commit`, `allow_rebase_merge`, `allow_squash_merge`, and `has_projects` to the `Repository` class. Note however that I ran into some trouble while modifying the `edit` method of the `Repository` class to make use of the new properties, specifically while writing tests, so I will fix the `edit` method in a future PR.
This commit is contained in:
committed by
Wan Liuyang
parent
1a90f5db5d
commit
2b352fb397
+47
-2
@@ -29,7 +29,7 @@
|
||||
# Copyright 2016 Dustin Spicuzza <dustin@virtualroadside.com> #
|
||||
# Copyright 2016 Enix Yu <enix223@163.com> #
|
||||
# Copyright 2016 Jannis Gebauer <ja.geb@me.com> #
|
||||
# Copyright 2016 Per Øyvind Karlsen <proyvind@moondrake.org> #
|
||||
# Copyright 2016 Per Øyvind Karlsen <proyvind@moondrake.org> #
|
||||
# Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> #
|
||||
# Copyright 2016 Sylvus <Sylvus@users.noreply.github.com> #
|
||||
# Copyright 2016 fukatani <nannyakannya@gmail.com> #
|
||||
@@ -41,7 +41,7 @@
|
||||
# Copyright 2017 Jannis Gebauer <ja.geb@me.com> #
|
||||
# Copyright 2017 Jason White <jasonwhite@users.noreply.github.com> #
|
||||
# Copyright 2017 Jimmy Zelinskie <jimmy.zelinskie+git@gmail.com> #
|
||||
# Copyright 2017 Nhomar Hernández [Vauxoo] <nhomar@vauxoo.com> #
|
||||
# Copyright 2017 Nhomar Hernández [Vauxoo] <nhomar@vauxoo.com> #
|
||||
# Copyright 2017 Simon <spam@esemi.ru> #
|
||||
# Copyright 2018 Andrew Smith <espadav8@gmail.com> #
|
||||
# Copyright 2018 Brian Torres-Gil <btorres-gil@paloaltonetworks.com> #
|
||||
@@ -52,6 +52,7 @@
|
||||
# Copyright 2018 Shinichi TAMURA <shnch.tmr@gmail.com> #
|
||||
# Copyright 2018 Wan Liuyang <tsfdye@gmail.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/ #
|
||||
@@ -126,6 +127,30 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
def __repr__(self):
|
||||
return self.get__repr__({"full_name": self._full_name.value})
|
||||
|
||||
@property
|
||||
def allow_merge_commit(self):
|
||||
"""
|
||||
:type: bool
|
||||
"""
|
||||
self._completeIfNotSet(self._allow_merge_commit)
|
||||
return self._allow_merge_commit.value
|
||||
|
||||
@property
|
||||
def allow_rebase_merge(self):
|
||||
"""
|
||||
:type: bool
|
||||
"""
|
||||
self._completeIfNotSet(self._allow_rebase_merge)
|
||||
return self._allow_rebase_merge.value
|
||||
|
||||
@property
|
||||
def allow_squash_merge(self):
|
||||
"""
|
||||
:type: bool
|
||||
"""
|
||||
self._completeIfNotSet(self._allow_squash_merge)
|
||||
return self._allow_squash_merge.value
|
||||
|
||||
@property
|
||||
def archived(self):
|
||||
"""
|
||||
@@ -350,6 +375,14 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
self._completeIfNotSet(self._has_issues)
|
||||
return self._has_issues.value
|
||||
|
||||
@property
|
||||
def has_projects(self):
|
||||
"""
|
||||
:type: bool
|
||||
"""
|
||||
self._completeIfNotSet(self._has_projects)
|
||||
return self._has_projects.value
|
||||
|
||||
@property
|
||||
def has_wiki(self):
|
||||
"""
|
||||
@@ -2536,6 +2569,9 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
return github.GitReleaseAsset.GitReleaseAsset(self._requester, resp_headers, data, completed=True)
|
||||
|
||||
def _initAttributes(self):
|
||||
self._allow_merge_commit = github.GithubObject.NotSet
|
||||
self._allow_rebase_merge = github.GithubObject.NotSet
|
||||
self._allow_squash_merge = github.GithubObject.NotSet
|
||||
self._archived = github.GithubObject.NotSet
|
||||
self._archive_url = github.GithubObject.NotSet
|
||||
self._assignees_url = github.GithubObject.NotSet
|
||||
@@ -2564,6 +2600,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
self._git_url = github.GithubObject.NotSet
|
||||
self._has_downloads = github.GithubObject.NotSet
|
||||
self._has_issues = github.GithubObject.NotSet
|
||||
self._has_projects = github.GithubObject.NotSet
|
||||
self._has_wiki = github.GithubObject.NotSet
|
||||
self._homepage = github.GithubObject.NotSet
|
||||
self._hooks_url = github.GithubObject.NotSet
|
||||
@@ -2612,6 +2649,12 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
self._watchers_count = github.GithubObject.NotSet
|
||||
|
||||
def _useAttributes(self, attributes):
|
||||
if "allow_merge_commit" in attributes: # pragma no branch
|
||||
self._allow_merge_commit = self._makeBoolAttribute(attributes["allow_merge_commit"])
|
||||
if "allow_rebase_merge" in attributes: # pragma no branch
|
||||
self._allow_rebase_merge = self._makeBoolAttribute(attributes["allow_rebase_merge"])
|
||||
if "allow_squash_merge" in attributes: # pragma no branch
|
||||
self._allow_squash_merge = self._makeBoolAttribute(attributes["allow_squash_merge"])
|
||||
if "archived" in attributes: # pragma no branch
|
||||
self._archived = self._makeBoolAttribute(attributes["archived"])
|
||||
if "archive_url" in attributes: # pragma no branch
|
||||
@@ -2668,6 +2711,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
self._has_downloads = self._makeBoolAttribute(attributes["has_downloads"])
|
||||
if "has_issues" in attributes: # pragma no branch
|
||||
self._has_issues = self._makeBoolAttribute(attributes["has_issues"])
|
||||
if "has_projects" in attributes: # pragma no branch
|
||||
self._has_projects = self._makeBoolAttribute(attributes["has_projects"])
|
||||
if "has_wiki" in attributes: # pragma no branch
|
||||
self._has_wiki = self._makeBoolAttribute(attributes["has_wiki"])
|
||||
if "homepage" in attributes: # pragma no branch
|
||||
|
||||
@@ -8,9 +8,10 @@
|
||||
# Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> #
|
||||
# Copyright 2016 Jannis Gebauer <ja.geb@me.com> #
|
||||
# Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> #
|
||||
# Copyright 2017 Balázs Rostás <rostas.balazs@gmail.com> #
|
||||
# Copyright 2017 Balázs Rostás <rostas.balazs@gmail.com> #
|
||||
# Copyright 2017 Jannis Gebauer <ja.geb@me.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/ #
|
||||
@@ -140,7 +141,8 @@ class AuthenticatedUser(Framework.TestCase):
|
||||
|
||||
def testCreateRepositoryWithAllArguments(self):
|
||||
repo = self.user.create_repo(name="TestPyGithub", description="Repo created by PyGithub", homepage="http://foobar.com",
|
||||
private=False, has_issues=False, has_wiki=False, has_downloads=False)
|
||||
private=False, has_issues=False, has_projects=False, has_wiki=False, has_downloads=False,
|
||||
allow_squash_merge=False, allow_merge_commit=False, allow_rebase_merge=True)
|
||||
self.assertEqual(repo.url, "https://api.github.com/repos/jacquev6/TestPyGithub")
|
||||
|
||||
def testCreateRepositoryWithAutoInit(self):
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
# Copyright 2017 Hugo <hugovk@users.noreply.github.com> #
|
||||
# Copyright 2017 Simon <spam@esemi.ru> #
|
||||
# Copyright 2018 sfdye <tsfdye@gmail.com> #
|
||||
# Copyright 2018 Jacopo Notarstefano <jacopo.notarstefano@gmail.com> #
|
||||
# #
|
||||
# This file is part of PyGithub. #
|
||||
# http://pygithub.readthedocs.io/ #
|
||||
@@ -115,7 +116,7 @@ class RecordingConnection: # pragma no cover (Class useful only when recording
|
||||
output = res.read()
|
||||
|
||||
self.__writeLine(str(status))
|
||||
self.__writeLine(str(headers))
|
||||
self.__writeLine(str(list(headers)))
|
||||
if atLeastPython3: # In Py3, return from "read" is bytes
|
||||
self.__writeLine(output)
|
||||
else:
|
||||
|
||||
@@ -198,7 +198,8 @@ class Organization(Framework.TestCase):
|
||||
def testCreateRepoWithAllArguments(self):
|
||||
team = self.org.get_team(141496)
|
||||
repo = self.org.create_repo(name="TestPyGithub2", description="Repo created by PyGithub", homepage="http://foobar.com",
|
||||
private=False, has_issues=False, has_wiki=False, has_downloads=False, team_id=team.id)
|
||||
private=False, has_issues=False, has_projects=False, has_wiki=False, has_downloads=False,
|
||||
team_id=team.id, allow_squash_merge=False, allow_merge_commit=False, allow_rebase_merge=True)
|
||||
self.assertEqual(repo.url, "https://api.github.com/repos/BeaverSoftware/TestPyGithub2")
|
||||
|
||||
def testCreateRepositoryWithAutoInit(self):
|
||||
|
||||
@@ -4,8 +4,8 @@ api.github.com
|
||||
None
|
||||
/user/repos
|
||||
{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
{"has_wiki": false, "name": "TestPyGithub", "has_downloads": false, "private": false, "has_issues": false, "homepage": "http://foobar.com", "description": "Repo created by PyGithub"}
|
||||
{"has_wiki": false, "name": "TestPyGithub", "has_downloads": false, "private": false, "has_issues": false, "homepage": "http://foobar.com", "description": "Repo created by PyGithub", "has_projects": false, "allow_squash_merge": false, "allow_merge_commit": false, "allow_rebase_merge": true}
|
||||
201
|
||||
[('status', '201 Created'), ('x-ratelimit-remaining', '4979'), ('content-length', '1111'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1c6473a60481c33b28a926041f763fce"'), ('date', 'Sat, 26 May 2012 09:55:27 GMT'), ('content-type', 'application/json; charset=utf-8'), ('location', 'https://api.github.com/repos/jacquev6/TestPyGithub')]
|
||||
{"clone_url":"https://github.com/jacquev6/TestPyGithub.git","has_downloads":false,"watchers":1,"git_url":"git://github.com/jacquev6/TestPyGithub.git","updated_at":"2012-05-26T09:55:27Z","permissions":{"pull":true,"admin":true,"push":true},"homepage":"http://foobar.com","url":"https://api.github.com/repos/jacquev6/TestPyGithub","has_wiki":false,"has_issues":false,"fork":false,"forks":1,"mirror_url":null,"size":0,"private":false,"open_issues":0,"svn_url":"https://github.com/jacquev6/TestPyGithub","owner":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"name":"TestPyGithub","language":null,"description":"Repo created by PyGithub","ssh_url":"git@github.com:jacquev6/TestPyGithub.git","pushed_at":"2012-05-26T09:55:27Z","created_at":"2012-05-26T09:55:27Z","id":4454027,"html_url":"https://github.com/jacquev6/TestPyGithub","full_name":"jacquev6/TestPyGithub"}
|
||||
{"clone_url":"https://github.com/jacquev6/TestPyGithub.git","has_downloads":false,"watchers":1,"git_url":"git://github.com/jacquev6/TestPyGithub.git","updated_at":"2012-05-26T09:55:27Z","permissions":{"pull":true,"admin":true,"push":true},"homepage":"http://foobar.com","url":"https://api.github.com/repos/jacquev6/TestPyGithub","has_wiki":false,"has_issues":false,"fork":false,"forks":1,"mirror_url":null,"size":0,"private":false,"open_issues":0,"svn_url":"https://github.com/jacquev6/TestPyGithub","owner":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"name":"TestPyGithub","language":null,"description":"Repo created by PyGithub","ssh_url":"git@github.com:jacquev6/TestPyGithub.git","pushed_at":"2012-05-26T09:55:27Z","created_at":"2012-05-26T09:55:27Z","id":4454027,"html_url":"https://github.com/jacquev6/TestPyGithub","full_name":"jacquev6/TestPyGithub", "has_projects": false, "allow_squash_merge": false, "allow_merge_commit": false, "allow_rebase_merge": true}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ api.github.com
|
||||
None
|
||||
/orgs/BeaverSoftware/repos
|
||||
{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
{"has_wiki": false, "name": "TestPyGithub2", "has_downloads": false, "private": false, "team_id": 141496, "has_issues": false, "homepage": "http://foobar.com", "description": "Repo created by PyGithub"}
|
||||
{"has_wiki": false, "name": "TestPyGithub2", "has_downloads": false, "private": false, "team_id": 141496, "has_issues": false, "homepage": "http://foobar.com", "description": "Repo created by PyGithub", "has_projects": false, "allow_squash_merge": false, "allow_merge_commit": false, "allow_rebase_merge": true}
|
||||
201
|
||||
[('status', '201 Created'), ('x-ratelimit-remaining', '4969'), ('content-length', '1501'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"feb513e01eaf8e89967068fe8ed44cc7"'), ('date', 'Sun, 27 May 2012 05:20:43 GMT'), ('content-type', 'application/json; charset=utf-8'), ('location', 'https://api.github.com/repos/BeaverSoftware/TestPyGithub2')]
|
||||
{"organization":{"url":"https://api.github.com/users/BeaverSoftware","gravatar_id":"d563e337cac2fdc644e2aaaad1e23266","avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","login":"BeaverSoftware","id":1424031},"clone_url":"https://github.com/BeaverSoftware/TestPyGithub2.git","has_downloads":false,"watchers":1,"updated_at":"2012-05-27T05:20:42Z","permissions":{"pull":true,"admin":true,"push":true},"homepage":"http://foobar.com","url":"https://api.github.com/repos/BeaverSoftware/TestPyGithub2","mirror_url":null,"has_wiki":false,"has_issues":false,"fork":false,"forks":1,"size":0,"private":false,"open_issues":0,"svn_url":"https://github.com/BeaverSoftware/TestPyGithub2","owner":{"url":"https://api.github.com/users/BeaverSoftware","gravatar_id":"d563e337cac2fdc644e2aaaad1e23266","avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","login":"BeaverSoftware","id":1424031},"name":"TestPyGithub2","language":null,"description":"Repo created by PyGithub","ssh_url":"git@github.com:BeaverSoftware/TestPyGithub2.git","pushed_at":"2012-05-27T05:20:42Z","created_at":"2012-05-27T05:20:42Z","id":4460019,"git_url":"git://github.com/BeaverSoftware/TestPyGithub2.git","html_url":"https://github.com/BeaverSoftware/TestPyGithub2","full_name":"BeaverSoftware/TestPyGithub2"}
|
||||
{"organization":{"url":"https://api.github.com/users/BeaverSoftware","gravatar_id":"d563e337cac2fdc644e2aaaad1e23266","avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","login":"BeaverSoftware","id":1424031},"clone_url":"https://github.com/BeaverSoftware/TestPyGithub2.git","has_downloads":false,"watchers":1,"updated_at":"2012-05-27T05:20:42Z","permissions":{"pull":true,"admin":true,"push":true},"homepage":"http://foobar.com","url":"https://api.github.com/repos/BeaverSoftware/TestPyGithub2","mirror_url":null,"has_wiki":false,"has_issues":false,"fork":false,"forks":1,"size":0,"private":false,"open_issues":0,"svn_url":"https://github.com/BeaverSoftware/TestPyGithub2","owner":{"url":"https://api.github.com/users/BeaverSoftware","gravatar_id":"d563e337cac2fdc644e2aaaad1e23266","avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","login":"BeaverSoftware","id":1424031},"name":"TestPyGithub2","language":null,"description":"Repo created by PyGithub","ssh_url":"git@github.com:BeaverSoftware/TestPyGithub2.git","pushed_at":"2012-05-27T05:20:42Z","created_at":"2012-05-27T05:20:42Z","id":4460019,"git_url":"git://github.com/BeaverSoftware/TestPyGithub2.git","html_url":"https://github.com/BeaverSoftware/TestPyGithub2","full_name":"BeaverSoftware/TestPyGithub2", "has_projects": false, "allow_squash_merge": false, "allow_merge_commit": false, "allow_rebase_merge": true}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user