Answer architecture round 1: 1 🔴, 2 🟡 (0 misread); read the branch's round titles and default branch one way for rule-hook and round-count

This commit is contained in:
2026-10-28 17:47:41 +01:00
parent 0254e427f2
commit fe975488ec
9 changed files with 75 additions and 42 deletions
+2 -7
View File
@@ -4,17 +4,12 @@ from failure import Failure
import git_repo
def git(directory: str, *args: str, timeout: float | None = None) -> str | Failure:
def git(directory: str, *args: str) -> str | Failure:
"""What git printed in directory, stripped, run guarded: the hook runs git in a checkout the call has not yet been allowed to touch."""
ran = git_repo.git(*args, cwd=directory, timeout=timeout, guarded=True)
ran = git_repo.git(*args, cwd=directory, guarded=True)
return ran if isinstance(ran, Failure) else ran.strip()
def local_default_branch(directory: str) -> str | None:
"""The default branch as the checkout last saw it, with no fetch, which the hook must not run."""
return next((name for name in ("origin/HEAD", "main", "master") if not isinstance(git(directory, "rev-parse", "--verify", "--quiet", name), Failure)), None)
def existing(directory: str) -> str:
path = pathlib.Path(directory or ".").absolute()
while not path.is_dir():