@@ -245,24 +245,37 @@ def sync_versions(self, version_repo):
245
245
``sync_versions`` endpoint.
246
246
"""
247
247
version_post_data = {'repo' : version_repo .repo_url }
248
+ tags = None
249
+ branches = None
250
+ if all ([
251
+ version_repo .supports_lsremote ,
252
+ not version_repo .repo_exists (),
253
+ self .project .has_feature (Feature .VCS_REMOTE_LISTING ),
254
+ ]):
255
+ # Do not use ``ls-remote`` if the VCS does not support it or if we
256
+ # have already cloned the repository locally. The latter happens
257
+ # when triggering a normal build.
258
+ branches , tags = version_repo .lsremote
248
259
249
260
if all ([
250
261
version_repo .supports_tags ,
251
262
not self .project .has_feature (Feature .SKIP_SYNC_TAGS )
252
263
]):
264
+ tags = tags or version_repo .tags
253
265
version_post_data ['tags' ] = [{
254
266
'identifier' : v .identifier ,
255
267
'verbose_name' : v .verbose_name ,
256
- } for v in version_repo . tags ]
268
+ } for v in tags ]
257
269
258
270
if all ([
259
271
version_repo .supports_branches ,
260
272
not self .project .has_feature (Feature .SKIP_SYNC_BRANCHES )
261
273
]):
274
+ branches = branches or version_repo .branches
262
275
version_post_data ['branches' ] = [{
263
276
'identifier' : v .identifier ,
264
277
'verbose_name' : v .verbose_name ,
265
- } for v in version_repo . branches ]
278
+ } for v in branches ]
266
279
267
280
self .validate_duplicate_reserved_versions (version_post_data )
268
281
@@ -372,7 +385,7 @@ def run(self, version_pk): # pylint: disable=arguments-differ
372
385
# all the other cached things (Python packages, Sphinx,
373
386
# virtualenv, etc)
374
387
self .pull_cached_environment ()
375
- self .sync_repo (environment )
388
+ self .update_versions_from_repository (environment )
376
389
return True
377
390
except RepositoryError :
378
391
# Do not log as ERROR handled exceptions
@@ -401,6 +414,24 @@ def run(self, version_pk): # pylint: disable=arguments-differ
401
414
# Always return False for any exceptions
402
415
return False
403
416
417
+ def update_versions_from_repository (self , environment ):
418
+ """
419
+ Update Read the Docs versions from VCS repository.
420
+
421
+ Depending if the VCS backend supports remote listing, we just list its branches/tags
422
+ remotely or we do a full clone and local listing of branches/tags.
423
+ """
424
+ version_repo = self .get_vcs_repo (environment )
425
+ if any ([
426
+ not version_repo .supports_lsremote ,
427
+ not self .project .has_feature (Feature .VCS_REMOTE_LISTING ),
428
+ ]):
429
+ log .info ('Syncing repository via full clone. project=%s' , self .projec .slug )
430
+ self .sync_repo (environment )
431
+ else :
432
+ log .info ('Syncing repository via remote listing. project=%s' , self .projec .slug )
433
+ self .sync_versions (version_repo )
434
+
404
435
405
436
@app .task (
406
437
bind = True ,
@@ -1116,6 +1147,8 @@ def setup_python_environment(self):
1116
1147
self .python_env .save_environment_json ()
1117
1148
self .python_env .install_core_requirements ()
1118
1149
self .python_env .install_requirements ()
1150
+ if self .project .has_feature (Feature .LIST_PACKAGES_INSTALLED_ENV ):
1151
+ self .python_env .list_packages_installed ()
1119
1152
1120
1153
def build_docs (self ):
1121
1154
"""
@@ -1170,7 +1203,7 @@ def build_docs_search(self):
1170
1203
For MkDocs search is indexed from its ``html`` artifacts.
1171
1204
And in sphinx is run using the rtd-sphinx-extension.
1172
1205
"""
1173
- return self .is_type_sphinx () and self . version . type != EXTERNAL
1206
+ return self .is_type_sphinx ()
1174
1207
1175
1208
def build_docs_localmedia (self ):
1176
1209
"""Get local media files with separate build."""
0 commit comments