From 577c04d537bab349c6614ea41084c4f6b0beb2a6 Mon Sep 17 00:00:00 2001 From: cliffmccarthy <16453869+cliffmccarthy@users.noreply.github.com> Date: Mon, 28 Jul 2025 16:30:33 -0500 Subject: [PATCH] feat: Add try blocks around Git commands in cmdeploy/__init__.py - Added 'try' blocks around the 'git rev-parse' and 'git diff' commands that are run in deploy_chatmail(). If there is an error running rev-parse, git_hash is set to "unknown". If there is an error running diff, git_diff is set to the null string. - This allows the deployment process work in two scenarios that would otherwise fail with an exception: - Systems where the 'git' command is not available. - When running with a copy of the tree content of chatmail/relay, but without a copy of the .git directory. --- cmdeploy/src/cmdeploy/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmdeploy/src/cmdeploy/__init__.py b/cmdeploy/src/cmdeploy/__init__.py index cd149a90..cb894750 100644 --- a/cmdeploy/src/cmdeploy/__init__.py +++ b/cmdeploy/src/cmdeploy/__init__.py @@ -816,8 +816,14 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None: name="Ensure cron is installed", packages=["cron"], ) - git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode() - git_diff = subprocess.check_output(["git", "diff"]).decode() + try: + git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode() + except Exception: + git_hash = "unknown\n" + try: + git_diff = subprocess.check_output(["git", "diff"]).decode() + except Exception: + git_diff = "" files.put( name="Upload chatmail relay git commiit hash", src=StringIO(git_hash + git_diff),