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:
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user