purge-old-deployments: Check /srv/zulip.git existence before pruning it.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2021-05-13 19:32:02 -07:00
committed by Tim Abbott
parent 6d4e7aa307
commit 6766a3f780

View File

@@ -14,6 +14,8 @@ from scripts.lib.zulip_tools import (
su_to_zulip, su_to_zulip,
) )
LOCAL_GIT_CACHE_DIR = "/srv/zulip.git"
def parse_args() -> argparse.Namespace: def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
@@ -75,8 +77,9 @@ def main() -> None:
) )
if not args.dry_run: if not args.dry_run:
if os.path.exists(LOCAL_GIT_CACHE_DIR):
subprocess.check_call( subprocess.check_call(
["git", "worktree", "prune"], cwd="/srv/zulip.git", preexec_fn=su_to_zulip ["git", "worktree", "prune"], cwd=LOCAL_GIT_CACHE_DIR, preexec_fn=su_to_zulip
) )
print("Deployments cleaned successfully...") print("Deployments cleaned successfully...")