[PATCH 10 of 17 v3] cli: repo-purge-deleted: improve reporting to user

Thomas De Schampheleire patrickdepinguin at gmail.com
Thu Oct 18 20:49:33 UTC 2018


# HG changeset patch
# User Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>
# Date 1539547789 -7200
#      Sun Oct 14 22:09:49 2018 +0200
# Node ID 3a3f3ae5620d39f43894afd82ec1a6701e25a2a1
# Parent  1053ff6d2643aa2851466c4a4d57bde5c80e7d8d
cli: repo-purge-deleted: improve reporting to user

diff --git a/kallithea/bin/kallithea_cli_repo.py b/kallithea/bin/kallithea_cli_repo.py
--- a/kallithea/bin/kallithea_cli_repo.py
+++ b/kallithea/bin/kallithea_cli_repo.py
@@ -147,9 +147,13 @@ def repo_purge_deleted(config_file, ask,
         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:
@@ -158,13 +162,18 @@ def repo_purge_deleted(config_file, ask,
                 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 = cli_util.ask_ok('The following repositories will be removed completely:\n%s\n'


More information about the kallithea-general mailing list