Skip to content

Commit 8ec9bc8

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 554c9e0 commit 8ec9bc8

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
@@ -830,8 +830,14 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
830830
name="Ensure cron is installed",
831831
packages=["cron"],
832832
)
833-
git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode()
834-
git_diff = subprocess.check_output(["git", "diff"]).decode()
833+
try:
834+
git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode()
835+
except Exception:
836+
git_hash = "unknown\n"
837+
try:
838+
git_diff = subprocess.check_output(["git", "diff"]).decode()
839+
except Exception:
840+
git_diff = ""
835841
files.put(
836842
name="Upload chatmail relay git commiit hash",
837843
src=StringIO(git_hash + git_diff),

0 commit comments

Comments
 (0)