Read a release whose items all moved to other releases as renamed, never finished

This commit is contained in:
2026-10-18 00:03:20 +02:00
parent e291f6ca3d
commit 32eb16cd20
13 changed files with 65 additions and 21 deletions
+15 -4
View File
@@ -19,7 +19,7 @@ MOVES = "Moves"
HEADER_START = "| ID | Release |"
# How the plan's earliest release stands to the version x.y.z the newest tag names, the last cut. "next": it is the earliest release after x.y.z that todo.md has named at that tag or since, or no tag names a version, or the tag cannot be read. "cut": it is x.y.z or earlier.
# Else the next release, the earliest named since the cut, holds no item: "finished" where work landed since the cut, and "unplanned" where none did. "unknown": todo.md's texts since the cut, or the count of work landed since it, cannot be read.
# A release named since the cut stays the next until a tag cuts it, even once its items moved to a later release, as larv_review/plan.py's emptied counts such a release emptied too.
# A release named since the cut stays the next until a tag cuts it, unless renamed says it was renamed; larv_review/plan.py's emptied counts a release the same way.
Standing = typing.Literal["next", "cut", "finished", "unplanned", "unknown"]
# todo.md's ## Details section, its body the first group.
DETAILS = re.compile(r"^## Details\n(.*?)(?=^## |\Z)", re.M | re.S)
@@ -186,7 +186,7 @@ class LastCut:
changelog: str | Failure
# How many commits follow the tag, or make up the branch where it has none.
commits: int | Failure
# todo.md's text at the tag and at each later commit that changed it; empty without a tag.
# todo.md's text at the tag and at each later commit that changed it, oldest first; empty without a tag.
todos_since: list[str] | Failure
@@ -203,10 +203,21 @@ def landed(cut: LastCut) -> int | Failure:
def named_releases(todos: list[str] | Failure) -> set[tuple[int, int, int]] | Failure:
"""Each release the todo.md texts file items under; a text that does not parse names none."""
"""Each release the todo.md texts, oldest first, file items under, less each that renamed says a later text renamed and none names again; a text that does not parse names none."""
if isinstance(todos, Failure):
return todos
return {item.release for parsed in map(items, todos) if isinstance(parsed, list) for item in parsed}
plans = [parsed for parsed in map(items, todos) if isinstance(parsed, list)]
named = {item.release for item in plans[0]} if plans else set()
for before, after in zip(plans, plans[1:]):
named = (named | {item.release for item in after}) - renamed(before, after)
return named
def renamed(before: list[Item], after: list[Item]) -> set[tuple[int, int, int]]:
"""Each release before names and after does not whose items after all holds: no item left the plan from it, so it was renamed, never finished, as `docs/decisions.md` → `todo.md: a release whose items all moved` says."""
held = {item.id for item in after}
gone = {item.release for item in before} - {item.release for item in after}
return {release for release in gone if all(item.id in held for item in before if item.release == release)}
def standing(tag: str | None | Failure, landed: int | Failure, earliest: tuple[int, int, int] | None, named: set[tuple[int, int, int]] | Failure) -> Standing: