[PATCH 1 of 2] repo-scan: don't print empty list of results

Thomas De Schampheleire thomas.de_schampheleire at nokia.com
Tue May 1 20:13:18 UTC 2018


# HG changeset patch
# User Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>
# Date 1525204314 -7200
#      Tue May 01 21:51:54 2018 +0200
# Node ID ab5ae5d0e2ba5b8189ce0040237e3a3ce3d3fe44
# Parent  d65b3b8f37c67a5cc17c7b1a70ac88f5a5bc9470
repo-scan: don't print empty list of results

If 'gearbox repo-scan' does not add nor remove anything, the output is:

    Now scanning root location for new repos ...
    Scan completed.
    Added: -
    Missing: -

These empty lists of results are not very helpful.
Instead, rework the code so that a list of added/removed/missing
repositories is only printed if it actually contains something.

diff --git a/kallithea/lib/paster_commands/repo_scan.py b/kallithea/lib/paster_commands/repo_scan.py
--- a/kallithea/lib/paster_commands/repo_scan.py
+++ b/kallithea/lib/paster_commands/repo_scan.py
@@ -46,14 +46,12 @@ class Command(BasePasterCommand):
         print 'Now scanning root location for new repos ...'
         added, removed = repo2db_mapper(ScmModel().repo_scan(),
                                         remove_obsolete=rm_obsolete)
-        added = ', '.join(added) or '-'
-        removed = ', '.join(removed) or '-'
         print 'Scan completed.'
-        print 'Added: %s' % added
-        if rm_obsolete:
-            print 'Removed: %s' % removed
-        else:
-            print 'Missing: %s' % removed
+        if added:
+            print 'Added: %s' % ', '.join(added)
+        if removed:
+            print '%s: %s' % ('Removed' if rm_obsolete else 'Missing',
+                              ', '.join(removed))
 
     def get_parser(self, prog_name):
         parser = super(Command, self).get_parser(prog_name)


More information about the kallithea-general mailing list