Answer stability round 2: 0 🔴, 2 🟡; take the next release as the earliest todo.md has named since the last cut, so an emptied patch or a major jump stops the loop too, count work landed by the Unreleased entries before commits, read the default branch once, and test the emptied release and the stalled origin through real git

This commit is contained in:
2026-10-17 02:34:15 +02:00
parent 4cf3c2bd8c
commit 5ba8920dbf
13 changed files with 224 additions and 142 deletions
+22 -10
View File
@@ -4,6 +4,7 @@ import re
import subprocess
from failure import Failure
from todo_table import LastCut
def git(*args: str, cwd: str | None = None, timeout: float | None = None) -> str | Failure:
@@ -67,19 +68,30 @@ class DefaultPlan:
ref: str
# todo.md's text, empty where the branch holds none.
todo: str | Failure
# The newest v* tag on the branch, None where it has none.
tag: str | None | Failure
# How many commits follow the tag, or make up the branch where it has none.
commits: int | Failure
cut: LastCut
def default_plan(root: str, timeout: float) -> DefaultPlan | Failure:
"""What the default branch as last fetched holds for the pick, read in the checkout at root. Asking origin, where the checkout records no default branch for it, fails after timeout seconds."""
ref = default_ref(root, timeout)
if isinstance(ref, Failure):
return ref
def default_plan(root: str, ref: str) -> DefaultPlan:
"""What ref, the default branch as last fetched, holds for the pick, read in the checkout at root."""
tag = newest_release_tag(ref, root)
return DefaultPlan(ref, file_at(ref, "todo.md", root), tag, tag if isinstance(tag, Failure) else commits_since(tag, ref, root))
commits = tag if isinstance(tag, Failure) else commits_since(tag, ref, root)
return DefaultPlan(ref, file_at(ref, "todo.md", root), LastCut(tag, file_at(ref, "CHANGELOG.md", root), commits, todos_since(tag, ref, root)))
def todos_since(tag: str | None | Failure, ref: str, cwd: str) -> list[str] | Failure:
"""todo.md's text at tag and at each later commit on ref that changed it, read in cwd; empty where there is no tag."""
if not isinstance(tag, str):
return []
changed = git("log", "--format=%H", f"{tag}..{ref}", "--", "todo.md", cwd=cwd)
if isinstance(changed, Failure):
return changed
texts = []
for commit in [tag, *changed.split()]:
text = file_at(commit, "todo.md", cwd)
if isinstance(text, Failure):
return text
texts.append(text)
return texts
def newest_release_tag(branch: str, cwd: str | None = None) -> str | None | Failure: