espnet3.utils.logging.get_git_metadata
Less than 1 minute
espnet3.utils.logging.get_git_metadata
espnet3.utils.logging.get_git_metadata(cwd: Path | None = None) → dict[str, str]
Return git metadata for the current repository.
This attempts to read commit hash, short hash, branch name, and worktree status from the git repository rooted at cwd.
- Parameters:cwd (Path | None) – Directory within the target git repo.
- Returns: Collected metadata keys, possibly including: : - ”commit”: Full commit hash.
- ”short_commit”: Abbreviated commit hash.
- ”branch”: Current branch name.
- ”worktree”: “clean”, “dirty”, or “unknown”.
- Return type: dict[str, str]
Example
>>> meta = get_git_metadata()
>>> meta.get("short_commit")