changeset 7412:e8c3241e5828

cli: repo-purge-deleted: improve reporting to user
author Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
date Sun, 14 Oct 2018 22:09:49 +0200
parents 977e7aca38b1
children 9de61c5b8694
files kallithea/bin/kallithea_cli_repo.py
diffstat 1 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/bin/kallithea_cli_repo.py	Sun Nov 18 20:02:17 2018 +0100
+++ b/kallithea/bin/kallithea_cli_repo.py	Sun Oct 14 22:09:49 2018 +0200
@@ -144,9 +144,13 @@
         if dirs:
             click.echo('Scanning: %s' % dn_)
 
+    if not to_remove:
+        click.echo('There are no deleted repositories.')
+        return
+
     # filter older than (if present)!
-    now = datetime.datetime.now()
     if older_than:
+        now = datetime.datetime.now()
         to_remove_filtered = []
         older_than_date = _parse_older_than(older_than)
         for name, date_ in to_remove:
@@ -155,13 +159,18 @@
                 to_remove_filtered.append([name, date_])
 
         to_remove = to_remove_filtered
-        click.echo('Purging %s deleted repos older than %s (%s)'
+
+        if not to_remove:
+            click.echo('There are no deleted repositories older than %s (%s)'
+                    % (older_than, older_than_date))
+            return
+
+        click.echo('Considering %s deleted repositories older than %s (%s).'
             % (len(to_remove), older_than, older_than_date))
     else:
-        click.echo('Purging all %s deleted repos' % len(to_remove))
+        click.echo('Considering %s deleted repositories.' % len(to_remove))
 
-    if not ask or not to_remove:
-        # don't ask just remove !
+    if not ask:
         remove = True
     else:
         remove = ask_ok('The following repositories will be removed completely:\n%s\n'