Skip to content

Commit bfd36b1

Browse files
committed
Adds support for both size and empty
Signed-off-by: Guyzmo <[email protected]>
1 parent 6ae13ca commit bfd36b1

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

gogs_client/entities.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,16 @@ class GogsRepo(GogsEntity):
9494
"""
9595

9696
def __init__(self, repo_id, owner, full_name, private, fork, default_branch,
97-
urls, permissions, json={}):
97+
empty, size, urls, permissions, json={}):
9898
super(GogsRepo, self).__init__(json=json)
9999
self._repo_id = repo_id
100100
self._owner = owner
101101
self._full_name = full_name
102102
self._private = private
103103
self._fork = fork
104104
self._default_branch = default_branch
105+
self._empty = empty
106+
self._size = size
105107
self._urls = urls
106108
self._permissions = permissions
107109

@@ -113,11 +115,14 @@ def from_json(parsed_json):
113115
private = json_get(parsed_json, "private")
114116
fork = json_get(parsed_json, "fork")
115117
default_branch = json_get(parsed_json, "default_branch")
118+
empty = json_get(parsed_json, "empty")
119+
size = json_get(parsed_json, "size")
116120
urls = GogsRepo.Urls(json_get(parsed_json, "html_url"), json_get(parsed_json, "clone_url"),
117121
json_get(parsed_json, "ssh_url"))
118122
permissions = GogsRepo.Permissions.from_json(json_get(parsed_json, "permissions"))
119123
return GogsRepo(repo_id=repo_id, owner=owner, full_name=full_name, private=private, fork=fork,
120-
default_branch=default_branch, urls=urls, permissions=permissions, json=parsed_json)
124+
default_branch=default_branch, empty=empty, size=size, urls=urls,
125+
permissions=permissions, json=parsed_json)
121126

122127
@property # named repo_id to avoid conflict with built-in id
123128
def repo_id(self):
@@ -173,6 +178,24 @@ def default_branch(self):
173178
"""
174179
return self._default_branch
175180

181+
@property
182+
def empty(self):
183+
"""
184+
Whether the repository is empty
185+
186+
:rtype: bool
187+
"""
188+
return self._empty
189+
190+
@property
191+
def size(self):
192+
"""
193+
Size of the repository
194+
195+
:rtype: int
196+
"""
197+
return self._size
198+
176199
@property
177200
def urls(self):
178201
"""

tests/interface_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ def setUp(self):
2727
"private": false,
2828
"fork": false,
2929
"default_branch": "master",
30+
"empty": false,
31+
"size": 42,
3032
"html_url": "http://localhost:3000/unknwon/Hello-World",
3133
"clone_url": "http://localhost:3000/unknwon/hello-world.git",
3234
"ssh_url": "jiahuachen@localhost:unknwon/hello-world.git",
@@ -49,6 +51,8 @@ def setUp(self):
4951
"private": false,
5052
"fork": false,
5153
"default_branch": "master",
54+
"empty": false,
55+
"size": 42,
5256
"html_url": "http://localhost:3000/unknwon/Hello-World",
5357
"clone_url": "http://localhost:3000/unknwon/hello-world.git",
5458
"ssh_url": "jiahuachen@localhost:unknwon/hello-world.git",
@@ -70,6 +74,8 @@ def setUp(self):
7074
"private": false,
7175
"fork": false,
7276
"default_branch": "master",
77+
"empty": false,
78+
"size": 42,
7379
"html_url": "http://localhost:3000/unknwon/Hello-World-Again",
7480
"clone_url": "http://localhost:3000/unknwon/hello-world-again.git",
7581
"ssh_url": "jiahuachen@localhost:unknwon/hello-world-again.git",

0 commit comments

Comments
 (0)