From 28d49edee39028d5d3393b3de0393a8bb4524921 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 17 Jun 2021 15:46:01 -0700 Subject: [PATCH] script: Add --no-headings option to purge-old-deployments. This parameter is somewhat useful, and adding this also fixes a regression where purge-old-deployments would crash since the changes around c5580607a7d8789627e70fc25ea5ba2a7a6bdb67 because of inconsistent supported args lists. --- scripts/lib/clean_yarn_cache.py | 3 ++- scripts/purge-old-deployments | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/lib/clean_yarn_cache.py b/scripts/lib/clean_yarn_cache.py index 1cc2687e05..a467618d32 100644 --- a/scripts/lib/clean_yarn_cache.py +++ b/scripts/lib/clean_yarn_cache.py @@ -31,13 +31,14 @@ def remove_unused_versions_dir(args: argparse.Namespace) -> None: except FileNotFoundError: return + no_headings = getattr(args, "no_headings", False) may_be_perform_purging( dirs_to_purge, {current_version_dir}, "yarn cache", args.dry_run, args.verbose, - args.no_headings, + no_headings, ) diff --git a/scripts/purge-old-deployments b/scripts/purge-old-deployments index 63e1bb3988..11c7b8e2a0 100755 --- a/scripts/purge-old-deployments +++ b/scripts/purge-old-deployments @@ -43,6 +43,13 @@ def parse_args() -> argparse.Namespace: action="store_true", help="If specified then script will print a detailed report of what is going on.", ) + parser.add_argument( + "--no-print-headings", + dest="no_headings", + action="store_true", + help="If specified then script will not print headings for " + "what will be deleted/kept back.", + ) args = parser.parse_args() args.verbose |= args.dry_run # Always print a detailed report in case of dry run. @@ -83,8 +90,9 @@ def main() -> None: ["git", "worktree", "prune"], cwd=LOCAL_GIT_CACHE_DIR, preexec_fn=su_to_zulip ) - print("Deployments cleaned successfully...") - print("Cleaning orphaned/unused caches...") + if not args.no_headings: + print("Deployments cleaned successfully...") + print("Cleaning orphaned/unused caches...") # Call 'clean_unused_caches.py' script to clean any orphaned/unused caches. clean_unused_caches.main(args)