judge.base_inputs(root, commit, name)
Read a unit, its bundle and its module from commit, not from the working tree.
A scratch worktree of commit is loaded with spotregen.load_spec, so a verdict can be reproduced from the commit alone. The worktree is removed again.
Parameters
| root |
Path |
Repository root. |
required |
| commit |
str |
A commit of the repository (a full SHA, from base_commit). |
required |
| name |
str |
The unit, as a dotted module name or its unique suffix. |
required |
Returns
| BaseInputs |
BaseInputs |
The unit, bundle, module text and hash, and the source directory. |
Raises
|
SpecError |
If name matches no unit at commit, or the records there do not load. |
Examples
import subprocess
from pathlib import Path
from tempfile import TemporaryDirectory
from spotregen import make_sample_repo
from spotregen.judge import base_inputs
def git(root, *args):
subprocess.run(
["git", "-c", "user.name=t", "-c", "user.email=t@example.org", *args],
cwd=root, check=True, capture_output=True,
)
with TemporaryDirectory() as tmp:
root = make_sample_repo(Path(tmp) / "demo")
git(root, "init", "-q")
git(root, "add", ".")
git(root, "commit", "-q", "-m", "init")
found = base_inputs(root, "HEAD", "core.calc")
print(found.unit.name, found.bundle.splitlines()[0])
samplepkg.core.calc # Regeneration bundle: samplepkg.core.calc