test: Handle Git errors in test_deployed_state()

- This is a counterpart to pull request #607.  Revised
  test_deployed_state() to perform the same error-handling on Git
  commands that cmdeploy does.  If 'git rev-parse' returns an error,
  the value "unknown" is used.  If 'git diff' returns an error, the
  null string is used.
- This fixes failures in environments where Git is not installed or
  where the .git subdirectory is not present (as long as the server
  was deployed in the same way).
This commit is contained in:
cliffmccarthy
2025-10-13 10:11:28 -05:00
committed by missytake
parent e7ddf6dc32
commit 21258a267a

View File

@@ -223,8 +223,14 @@ def test_expunged(remote, chatmail_config):
def test_deployed_state(remote): def test_deployed_state(remote):
git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode() try:
git_diff = subprocess.check_output(["git", "diff"]).decode() 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 = ""
git_status = [git_hash.strip()] git_status = [git_hash.strip()]
for line in git_diff.splitlines(): for line in git_diff.splitlines():
git_status.append(line.strip().lower()) git_status.append(line.strip().lower())