Skip to content

Commit 577c04d

Browse files
cliffmccarthymissytake
authored andcommitted
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.
1 parent d880937 commit 577c04d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cmdeploy/src/cmdeploy/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,14 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
816816
name="Ensure cron is installed",
817817
packages=["cron"],
818818
)
819-
git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode()
820-
git_diff = subprocess.check_output(["git", "diff"]).decode()
819+
try:
820+
git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode()
821+
except Exception:
822+
git_hash = "unknown\n"
823+
try:
824+
git_diff = subprocess.check_output(["git", "diff"]).decode()
825+
except Exception:
826+
git_diff = ""
821827
files.put(
822828
name="Upload chatmail relay git commiit hash",
823829
src=StringIO(git_hash + git_diff),

0 commit comments

Comments
 (0)