review.runs.file_at(root, commit, path)
The text of a project file at commit, wherever the project lies in its repository.
Parameters
| root |
Path |
The project root; it may be a subfolder of the repository. |
required |
| commit |
str |
A commit-ish, usually [base].commit of a run. |
required |
| path |
str |
The file, relative to root, with / separators. |
required |
Raises
|
ConfigurationError |
If the file does not exist at commit. |
Examples
import subprocess
from pathlib import Path
from tempfile import TemporaryDirectory
from babregen import make_sample_repo
from babregen.review.runs import file_at
with TemporaryDirectory() as tmp:
root = make_sample_repo(Path(tmp) / "demo")
git = ["git", "-c", "user.name=t", "-c", "user.email=t@e.org"]
subprocess.run(["git", "init", "-q"], cwd=root, check=True)
subprocess.run(["git", "add", "."], cwd=root, check=True)
subprocess.run([*git, "commit", "-qm", "x"], cwd=root, check=True)
print(file_at(root, "HEAD", "regen/architecture.toml").splitlines()[0])