upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRomain PINSOLLE <romain.pins@gmail.com>2026-11-24 10:53:11 +0100
committerRomain PINSOLLE <romain.pins@gmail.com>2026-11-24 10:53:11 +0100
commit5abe553f5fcc1e373ebf4f9e640cf2aec79b69e7 (patch)
tree50b367219ddf4bdccc8db354ce7fbc6c25a17fd7 /scripts
parent21625bca8c675c62f9dbffc318ce6a59d57faf31 (diff)
merge_check: exit 2 when git cannot be run (MERGE-CHECK-GIT-MISSING)
The docstring promises exit 2 on a git error. When git is not on PATH, subprocess.run raised FileNotFoundError, which escaped main() as a traceback with exit 1. The git() helper now turns the OSError into a GitError, so the message reads "merge_check: cannot run git: ..." and the exit code is 2. Tests cover a patched FileNotFoundError, an empty PATH, and a folder that is not a repository (git exits nonzero; still exit 2).
Diffstat (limited to 'scripts')
-rw-r--r--scripts/merge_check.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/scripts/merge_check.py b/scripts/merge_check.py
index c4cbdceca..a5a098964 100644
--- a/scripts/merge_check.py
+++ b/scripts/merge_check.py
@@ -42,7 +42,10 @@ class GitError(Exception):
42 42
43 43
44def git(repo, *args, check=True): 44def git(repo, *args, check=True):
45 r = subprocess.run(["git", "-C", repo, *args], capture_output=True) 45 try:
46 r = subprocess.run(["git", "-C", repo, *args], capture_output=True)
47 except OSError as e: # git is not on PATH, or cannot be executed: a usage error (exit 2), not a traceback
48 raise GitError(f"cannot run git: {e.strerror or e}") from None
46 # Decode without universal-newline translation: a bare CR inside a Git line is content. 49 # Decode without universal-newline translation: a bare CR inside a Git line is content.
47 r.stdout = r.stdout.decode("utf-8", "replace") 50 r.stdout = r.stdout.decode("utf-8", "replace")
48 r.stderr = r.stderr.decode("utf-8", "replace") 51 r.stderr = r.stderr.decode("utf-8", "replace")