Answer principles round 1: 0 🔴, 3 🟡 (0 misread); hand the home folder, the clock and the output to larv-review's commands from their wiring
This commit is contained in:
@@ -19,15 +19,15 @@ OWN = pathlib.Path(__file__).resolve().parents[2]
|
||||
OWN_CHECK_SECONDS = 20
|
||||
|
||||
|
||||
def todo_breaches(directory: str, own: pathlib.Path = OWN) -> list[Breach]:
|
||||
def todo_breaches(directory: str, home: pathlib.Path, own: pathlib.Path = OWN) -> list[Breach]:
|
||||
"""Why the plan of directory's project is not ranked, where the plan has changed; the plan is the todo.md its config names. directory may also be in a config's folder, a git repo of its own."""
|
||||
top = guarded_git(directory, "rev-parse", "--show-toplevel")
|
||||
if isinstance(top, Failure):
|
||||
return []
|
||||
held_here = held(pathlib.Path(top), pathlib.Path.home())
|
||||
held_here = held(pathlib.Path(top), home)
|
||||
if held_here is not None:
|
||||
return folder_breaches(top, held_here, own)
|
||||
config = located(top, pathlib.Path.home(), functools.partial(git, guarded=True))
|
||||
config = located(top, home, functools.partial(git, guarded=True))
|
||||
if isinstance(config, Failure):
|
||||
# A checkout whose todo.md changes with no config is one whose config is still to write. An unchanged todo.md may be a third party's, whose clone needs no config.
|
||||
unconfigured = pathlib.Path(top) / "todo.md"
|
||||
@@ -78,6 +78,10 @@ def changed(top: str, todo: pathlib.Path, tracked: str) -> bool:
|
||||
# Hashed here, never by `git status`, which would run a clean filter the checkout's own config names before the call is allowed.
|
||||
staged, committed = guarded_git(top, "rev-parse", f":{tracked}"), guarded_git(top, "rev-parse", f"HEAD:{tracked}")
|
||||
algorithm = guarded_git(top, "rev-parse", "--show-object-format")
|
||||
content = todo.read_bytes()
|
||||
try:
|
||||
content = todo.read_bytes()
|
||||
except OSError:
|
||||
# An unreadable plan counts as changed, so the check runs and its breach says why the plan cannot be read. Raising here would end the hook with an exit that lets the commit through unchecked.
|
||||
return True
|
||||
worktree = hashlib.new("sha1" if isinstance(algorithm, Failure) else algorithm, b"blob %d\0" % len(content) + content).hexdigest()
|
||||
return isinstance(staged, Failure) or staged != worktree or staged != committed
|
||||
|
||||
Reference in New Issue
Block a user