Source code for torx.performance.git_information_m

"""Utilities for retrieving git repository metadata."""
import warnings
from torx.performance import sys_call

[docs] def get_git_hash() -> str: """ Return the git hash of the current repository HEAD. Returns ------- str The full git hash, or "NA" if it cannot be retrieved. """ try: return sys_call(["git", "rev-parse", "HEAD"]) or "NA" except EnvironmentError: warnings.warn("Could not retrieve git hash") return "NA"
[docs] def get_git_email() -> str: """ Return the git user email from the current repository config. Returns ------- str The git user email, or "NA" if it cannot be retrieved. """ try: return sys_call(["git", "config", "user.email"]) or "NA" except EnvironmentError: warnings.warn("Could not retrieve git user email") return "NA"