@@ -106,7 +106,8 @@ def _log(self, msg):
106
106
107
107
# pylint: disable=arguments-differ
108
108
def run (self , pk , version_pk = None , build_pk = None , record = True ,
109
- docker = False , search = True , force = False , localmedia = True , ** __ ):
109
+ docker = False , search = True , force = False , localmedia = True ,
110
+ sync_only = False , ** __ ):
110
111
"""
111
112
Run a documentation sync or sync n' build.
112
113
@@ -144,9 +145,15 @@ def run(self, pk, version_pk=None, build_pk=None, record=True,
144
145
self .build_force = force
145
146
self .config = None
146
147
148
+ if sync_only :
149
+ self .sync_repo ()
150
+ return True
151
+
147
152
setup_successful = self .run_setup (record = record )
148
153
if not setup_successful :
149
154
return False
155
+
156
+
150
157
# Catch unhandled errors in the setup step
151
158
except Exception as e : # noqa
152
159
log .exception (
@@ -365,7 +372,8 @@ def sync_repo(self):
365
372
)
366
373
version_repo = self .project .vcs_repo (
367
374
self .version .slug ,
368
- self .setup_env ,
375
+ # When ``sync_only`` we don't a setup_env
376
+ getattr (self , 'setup_env' , None ),
369
377
)
370
378
version_repo .checkout (self .version .identifier )
371
379
finally :
@@ -607,88 +615,6 @@ def send_notifications(self):
607
615
send_notifications .delay (self .version .pk , build_pk = self .build ['id' ])
608
616
609
617
610
- @app .task ()
611
- def update_imported_docs (version_pk , env = None ):
612
- """
613
- Check out or update the given project's repository.
614
-
615
- :param version_pk: Version id to update
616
- """
617
- version_data = api_v2 .version (version_pk ).get ()
618
- version = APIVersion (** version_data )
619
- project = version .project
620
- ret_dict = {}
621
-
622
- # Make Dirs
623
- if not os .path .exists (project .doc_path ):
624
- os .makedirs (project .doc_path )
625
-
626
- if not project .vcs_repo ():
627
- raise RepositoryError (
628
- _ ('Repository type "{repo_type}" unknown' ).format (
629
- repo_type = project .repo_type
630
- )
631
- )
632
-
633
- with project .repo_nonblockinglock (
634
- version = version ,
635
- max_lock_age = getattr (settings , 'REPO_LOCK_SECONDS' , 30 )):
636
-
637
- # Get the actual code on disk
638
- try :
639
- before_vcs .send (sender = version )
640
- if version :
641
- log .info (
642
- LOG_TEMPLATE .format (
643
- project = project .slug ,
644
- version = version .slug ,
645
- msg = 'Checking out version {slug}: {identifier}' .format (
646
- slug = version .slug ,
647
- identifier = version .identifier
648
- )
649
- )
650
- )
651
- version_slug = version .slug
652
- version_repo = project .vcs_repo (version_slug )
653
-
654
- ret_dict ['checkout' ] = version_repo .checkout (version .identifier , env )
655
- else :
656
- # Does this ever get called?
657
- log .info (LOG_TEMPLATE .format (
658
- project = project .slug , version = version .slug , msg = 'Updating to latest revision' ))
659
- version_slug = LATEST
660
- version_repo = project .vcs_repo (version_slug )
661
- ret_dict ['checkout' ] = version_repo .update ()
662
- finally :
663
- after_vcs .send (sender = version )
664
-
665
- # Update tags/version
666
-
667
- version_post_data = {'repo' : version_repo .repo_url }
668
-
669
- if version_repo .supports_tags :
670
- version_post_data ['tags' ] = [
671
- {'identifier' : v .identifier ,
672
- 'verbose_name' : v .verbose_name ,
673
- } for v in version_repo .tags
674
- ]
675
-
676
- if version_repo .supports_branches :
677
- version_post_data ['branches' ] = [
678
- {'identifier' : v .identifier ,
679
- 'verbose_name' : v .verbose_name ,
680
- } for v in version_repo .branches
681
- ]
682
-
683
- try :
684
- api_v2 .project (project .pk ).sync_versions .post (version_post_data )
685
- except HttpClientError :
686
- log .exception ("Sync Versions Exception" )
687
- except Exception :
688
- log .exception ("Unknown Sync Versions Exception" )
689
- return ret_dict
690
-
691
-
692
618
# Web tasks
693
619
@app .task (queue = 'web' )
694
620
def sync_files (project_pk , version_pk , hostname = None , html = False ,
0 commit comments