trader.versioning module

Detecting which git commit this process is actually running (issue #30).

git rev-parse is a subprocess call — the first one in this codebase — and it is sandboxed to this module, never raising: a future packaged deploy that is not a live git checkout must not block trader run/run-once from starting over a version-log nicety.

trader.versioning.UNKNOWN_GIT_SHA = 'unknown'

Recorded explicitly when the SHA cannot be determined at all — never a guess. Same “unknown is not zero” discipline as the fill-poll settle guard and the missing-analyst-coverage check.

trader.versioning.detect_git_version(cwd=None)[source]

(git_sha, git_ref) for the checkout at cwd (default: the CWD).

git_sha is UNKNOWN_GIT_SHA when it cannot be read at all — no git on PATH, not a git checkout, or any other failure. git_ref is None whenever no branch name resolves (detached HEAD, or the SHA itself is unknown) — never a guess at which branch is running.

Parameters:

cwd (Path | None)

Return type:

tuple[str, str | None]