This commit is contained in:
Félix Dorn 2025-07-03 19:40:35 +02:00
parent b7c94590f9
commit f9f9825abb
9 changed files with 941 additions and 42 deletions

View file

@ -26,4 +26,16 @@ def _get_current_commit() -> str:
"""
Returns the current git commit hash, "unknown", or "errored" depending on why the commit could not be retrieved.
"""
raise NotImplementedError
import subprocess
try:
# Get the current commit hash
commit_hash = subprocess.check_output(
["git", "rev-parse", "HEAD"], stderr=subprocess.PIPE, text=True
).strip()
return commit_hash
except subprocess.CalledProcessError:
# If git command fails (e.g., not a git repository)
return "errored"
except FileNotFoundError:
# If git is not installed
return "unknown"