@@ -128,7 +128,7 @@ def add_collaborator(self, username):
128
128
return False
129
129
url = self ._build_url ('collaborators' , str (username ),
130
130
base_url = self ._api )
131
- return self ._boolean (self ._put (url ), 204 , 404 )
131
+ return self ._boolean (self ._put (url ), 201 , 404 )
132
132
133
133
def archive (self , format , path = '' , ref = 'master' ):
134
134
"""Get the tarball or zipball archive for this repo at ref.
@@ -956,7 +956,7 @@ def directory_contents(self, directory_path, ref=None, return_as=list):
956
956
@requires_auth
957
957
def edit (self , name , description = None , homepage = None , private = None ,
958
958
has_issues = None , has_wiki = None , has_downloads = None ,
959
- default_branch = None ):
959
+ default_branch = None , archived = None ):
960
960
"""Edit this repository.
961
961
962
962
:param str name: (required), name of the repository
@@ -980,12 +980,15 @@ def edit(self, name, description=None, homepage=None, private=None,
980
980
:param str default_branch: (optional), If not ``None``, change the
981
981
default branch for this repository. API default: ``None`` - leave
982
982
value unchanged.
983
+ :param bool archived: (optional), If not ``None``, toggle the archived
984
+ attribute on the repository to control whether it is archived or
985
+ not.
983
986
:returns: bool -- True if successful, False otherwise
984
987
"""
985
988
edit = {'name' : name , 'description' : description , 'homepage' : homepage ,
986
989
'private' : private , 'has_issues' : has_issues ,
987
990
'has_wiki' : has_wiki , 'has_downloads' : has_downloads ,
988
- 'default_branch' : default_branch }
991
+ 'default_branch' : default_branch , 'archived' : archived }
989
992
self ._remove_none (edit )
990
993
json = None
991
994
if edit :
@@ -1029,13 +1032,13 @@ def forks(self, sort='', number=-1, etag=None):
1029
1032
returns all forks
1030
1033
:param str etag: (optional), ETag from a previous request to the same
1031
1034
endpoint
1032
- :returns: generator of :class:`Repository <Repository> `
1035
+ :returns: generator of :class:`~github3.repos.repo.ShortRepository `
1033
1036
"""
1034
1037
url = self ._build_url ('forks' , base_url = self ._api )
1035
1038
params = {}
1036
1039
if sort in ('newest' , 'oldest' , 'watchers' ):
1037
1040
params = {'sort' : sort }
1038
- return self ._iter (int (number ), url , Repository , params , etag )
1041
+ return self ._iter (int (number ), url , ShortRepository , params , etag )
1039
1042
1040
1043
def git_commit (self , sha ):
1041
1044
"""Get a single (git) commit.
@@ -1172,7 +1175,7 @@ def import_issue(self, title, body, created_at, assignee=None,
1172
1175
data = self ._post (url , data = issue ,
1173
1176
headers = ImportedIssue .IMPORT_CUSTOM_HEADERS )
1174
1177
1175
- json = self ._json (data , 200 )
1178
+ json = self ._json (data , 202 )
1176
1179
return self ._instance_or_null (ImportedIssue , json )
1177
1180
1178
1181
def is_assignee (self , username ):
@@ -2107,6 +2110,11 @@ class Repository(_Repository):
2107
2110
This object has all the same attributes as
2108
2111
:class:`~github3.repos.repo.ShortRepository` as well as:
2109
2112
2113
+ .. attribute:: archived
2114
+
2115
+ A boolean attribute that describes whether the current repository has
2116
+ been archived or not.
2117
+
2110
2118
.. attribute:: clone_url
2111
2119
2112
2120
This is the URL that can be used to clone the repository via HTTPS,
@@ -2178,6 +2186,12 @@ class Repository(_Repository):
2178
2186
2179
2187
The number of issues currently open on the repository.
2180
2188
2189
+ .. attribute:: parent
2190
+
2191
+ A representation of the parent repository as
2192
+ :class:`~github3.repos.repo.ShortRepository`. If this Repository has
2193
+ no parent then this will be ``None``.
2194
+
2181
2195
.. attribute:: pushed_at
2182
2196
2183
2197
A parsed :class:`~datetime.datetime` object representing the date a
@@ -2187,6 +2201,12 @@ class Repository(_Repository):
2187
2201
2188
2202
The size of the repository.
2189
2203
2204
+ .. attribute:: source
2205
+
2206
+ A representation of the source repository as
2207
+ :class:`~github3.repos.repo.ShortRepository`. If this Repository has
2208
+ no source then this will be ``None``.
2209
+
2190
2210
.. attribute:: ssh_url
2191
2211
2192
2212
This is the URL that can be used to clone the repository via the SSH
@@ -2223,6 +2243,7 @@ class Repository(_Repository):
2223
2243
2224
2244
def _update_attributes (self , repo ):
2225
2245
super (Repository , self )._update_attributes (repo )
2246
+ self .archived = repo ['archived' ]
2226
2247
self .clone_url = repo ['clone_url' ]
2227
2248
self .created_at = self ._strptime (repo ['created_at' ])
2228
2249
self .default_branch = repo ['default_branch' ]
@@ -2232,68 +2253,31 @@ def _update_attributes(self, repo):
2232
2253
self .has_downloads = repo ['has_downloads' ]
2233
2254
self .has_issues = repo ['has_issues' ]
2234
2255
self .has_pages = repo ['has_pages' ]
2256
+ self .has_projects = repo ['has_projects' ]
2235
2257
self .has_wiki = repo ['has_wiki' ]
2236
2258
self .homepage = repo ['homepage' ]
2237
2259
self .language = repo ['language' ]
2260
+ self .original_license = repo ['license' ]
2261
+ if self .original_license is not None :
2262
+ self .original_license = License (self .original_license , self )
2238
2263
self .mirror_url = repo ['mirror_url' ]
2264
+ self .network_count = repo ['network_count' ]
2239
2265
self .open_issues_count = repo ['open_issues_count' ]
2266
+ self .parent = repo .get ('parent' , None )
2267
+ if self .parent is not None :
2268
+ self .parent = ShortRepository (self .parent , self )
2240
2269
self .pushed_at = self ._strptime (repo ['pushed_at' ])
2241
2270
self .size = repo ['size' ]
2271
+ self .source = repo .get ('source' , None )
2272
+ if self .source is not None :
2273
+ self .source = ShortRepository (self .source , self )
2242
2274
self .ssh_url = repo ['ssh_url' ]
2243
2275
self .stargazers_count = repo ['stargazers_count' ]
2276
+ self .subscribers_count = repo ['subscribers_count' ]
2244
2277
self .svn_url = self ._get_attribute (repo , 'svn_url' )
2245
2278
self .updated_at = self ._strptime_attribute (repo , 'updated_at' )
2246
2279
self .watchers_count = self .watchers = repo ['watchers_count' ]
2247
2280
2248
- # Some repositories do not have these attributes at all
2249
- self .original_license = repo .get ('license' )
2250
- if self .original_license is not None :
2251
- self .original_license = License (self .original_license , self )
2252
- self .network_count = repo .get ('network_count' )
2253
- self .subscribers_count = repo .get ('subscribers_count' )
2254
-
2255
- # .......... OLD ...... Deprecated?
2256
-
2257
- #: URL of the pure diff of the pull request
2258
- self .diff_url = self ._get_attribute (repo , 'diff_url' )
2259
-
2260
- #: URL of the pure patch of the pull request
2261
- self .patch_url = self ._get_attribute (repo , 'patch_url' )
2262
-
2263
- #: API URL of the issue representation of this Pull Request
2264
- self .issue_url = self ._get_attribute (repo , 'issue_url' )
2265
-
2266
- #: Permissions for this repository
2267
- self .permissions = self ._get_attribute (repo , 'permissions' )
2268
-
2269
- #: ``datetime`` object representing when the repository was starred
2270
- self .starred_at = self ._strptime_attribute (repo , 'starred_at' )
2271
-
2272
- #: Parent of this fork, if it exists :class:`Repository`
2273
- self .source = self ._class_attribute (repo , 'source' , Repository , self )
2274
-
2275
- #: Parent of this fork, if it exists :class:`Repository`
2276
- self .parent = self ._class_attribute (repo , 'parent' , Repository , self )
2277
-
2278
- #: master (default) branch for the repository
2279
- self .master_branch = self ._get_attribute (repo , 'master_branch' )
2280
-
2281
- # Template URLS
2282
-
2283
- #: Pull Request Review Comments URL
2284
- self .review_comments_url = self ._class_attribute (
2285
- repo ,
2286
- 'review_comments_url' ,
2287
- URITemplate
2288
- )
2289
-
2290
- #: Pull Request Review Comments URL Template. Expand with ``number``
2291
- self .issue_events_urlt = self ._class_attribute (
2292
- repo ,
2293
- 'review_comment_url' ,
2294
- URITemplate
2295
- )
2296
-
2297
2281
2298
2282
class StarredRepository (GitHubCore ):
2299
2283
"""This object represents the data returned about a user's starred repos.
@@ -2320,7 +2304,7 @@ class StarredRepository(GitHubCore):
2320
2304
2321
2305
def _update_attributes (self , starred_repository ):
2322
2306
self .starred_at = self ._strptime (starred_repository ['starred_at' ])
2323
- self .repository = Repository (starred_repository ['repo' ], self )
2307
+ self .repository = ShortRepository (starred_repository ['repo' ], self )
2324
2308
self .repo = self .repository
2325
2309
2326
2310
def _repr (self ):
0 commit comments