chiark / gitweb /
server: show progress bar when pushing git mirrors
authorHans-Christoph Steiner <hans@eds.org>
Tue, 11 Apr 2017 21:49:10 +0000 (23:49 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Wed, 12 Apr 2017 13:04:05 +0000 (15:04 +0200)
The git mirrors can be really slow to upload, so they need a progress bar.

fdroidserver/server.py

index 93ef256395178a7a5acdfddb0ea21695e7ff97cc..ae3d8c9a24140f93d3b2a26b1d678df29a7aa21d 100644 (file)
@@ -315,6 +315,7 @@ def update_servergitmirrors(servergitmirrors, repo_section):
 
     '''
     import git
+    from clint.textui import progress
     if config.get('local_copy_dir') \
        and not config.get('sync_from_local_copy_dir'):
         logging.debug('Offline machine, skipping git mirror generation until `fdroid server update`')
@@ -340,12 +341,27 @@ def update_servergitmirrors(servergitmirrors, repo_section):
             logging.info('Mirroring to: ' + mirror)
 
         # sadly index.add don't allow the --all parameter
+        logging.debug('Adding all files to git mirror')
         repo.git.add(all=True)
+        logging.debug('Committing all files into git mirror')
         repo.index.commit("fdroidserver git-mirror")
 
+        if options.verbose:
+            bar = progress.Bar()
+
+            class MyProgressPrinter(git.RemoteProgress):
+                def update(self, op_code, current, maximum=None, message=None):
+                    if isinstance(maximum, float):
+                        bar.show(current, maximum)
+            progress = MyProgressPrinter()
+        else:
+            progress = None
         # push for every remote. This will overwrite the git history
         for remote in repo.remotes:
-            remote.push('master', force=True, set_upstream=True)
+            logging.debug('Pushing to ' + remote.url)
+            remote.push('master', force=True, set_upstream=True, progress=progress)
+        if progress:
+            bar.done()
 
 
 def upload_to_android_observatory(repo_section):