The full SHA of HEAD, if the working tree is clean.
Untracked files below regen/runs/ (earlier runs) do not make the tree dirty.
Parameters
| root |
Path |
Repository root. |
required |
Returns
| str |
str |
The 40-hex SHA of HEAD. |
Raises
|
ConfigurationError |
If a tracked file has a change, or an untracked file lies outside regen/runs/, or root is not a git repository with a commit. |
Examples
import subprocess
from pathlib import Path
from tempfile import TemporaryDirectory
from spotregen.judge import base_commit
with TemporaryDirectory() as tmp:
root = Path(tmp)
for args in (["init", "-q"], ["commit", "-q", "--allow-empty", "-m", "i"]):
subprocess.run(
["git", "-c", "user.name=t", "-c", "user.email=t@example.org", *args],
cwd=root, check=True, capture_output=True,
)
print(len(base_commit(root)))