Count a cut release's open items as the next release's
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
"""The pure choices the preflight's steps act on."""
|
||||
import pathlib
|
||||
|
||||
from release_plan.release_standing import chunk_item, Cut, dated_cut, LastCut, ReadyToCut, ReviewDue, Unknown, Unplanned
|
||||
from release_plan.release_standing import carried, chunk_item, Cut, dated_cut, LastCut, ReadyToCut, ReviewDue, Unknown, Unplanned
|
||||
from failure import Failure
|
||||
from chunk_preflight.gathered import Forge, NoItem, Plan
|
||||
from chunk_preflight.gathered import CarriedOver, Forge, NoItem, Plan
|
||||
from release_plan.todo_table import NoItemsTable
|
||||
from plan_store import stores as plan_stores
|
||||
from release_plan.release import version
|
||||
@@ -52,7 +52,10 @@ def planned(todo: plan_stores.Plan | Failure, cut: LastCut, default: str, branch
|
||||
first = pick.item
|
||||
if first is None:
|
||||
return NoItem(f"every item of release {version(pick.release)} in {where} waits." if pick.release is not None else f"{where}'s items table holds no item.")
|
||||
return Plan(found, first, f"{first.tagline}\n\n{first.detail}".strip(), branch)
|
||||
moved = [(was, now) for was, now in zip(found, carried(found, cut)) if was.release != now.release]
|
||||
# Every carried item takes one release, the next; the newest release they were filed under names the cut.
|
||||
over = CarriedOver(max(was.release for was, _ in moved), moved[0][1].release, tuple(was.id for was, _ in moved)) if moved else None
|
||||
return Plan(carried(found, cut), first, f"{first.tagline}\n\n{first.detail}".strip(), branch, over)
|
||||
|
||||
|
||||
def worktree_on(porcelain: str, branch: str) -> pathlib.Path | None:
|
||||
|
||||
@@ -46,6 +46,7 @@ def item_lines(plan: str, item: ItemFacts) -> list[str]:
|
||||
worktree = item.worktree.reason if isinstance(item.worktree, Failure) else f"{item.worktree.path}, {item.worktree.how}"
|
||||
return [
|
||||
f"- The earliest release in {plan}: {version(first.release)}. Its first item that does not wait: item {first.id}, {levels(first)}.",
|
||||
*carried_lines(item.plan),
|
||||
f"- Worktree: {worktree}",
|
||||
f"- Open pull requests from {item.plan.branch}: {pulls_text(item.pulls, item.plan.branch)}",
|
||||
*bundled(item.plan),
|
||||
@@ -57,6 +58,15 @@ def item_lines(plan: str, item: ItemFacts) -> list[str]:
|
||||
]
|
||||
|
||||
|
||||
def carried_lines(plan: Plan) -> list[str]:
|
||||
"""What the worker does about the items of a release someone cut while it held them."""
|
||||
over = plan.carried
|
||||
if over is None:
|
||||
return []
|
||||
items, count, them = (f"Items {listed([str(id_) for id_ in over.ids], 'and')} are", "they count", "them") if len(over.ids) > 1 else (f"Item {over.ids[0]} is", "it counts", "it")
|
||||
return [f"- {items} filed under release {version(over.cut)}, which is cut, so {count} as release {version(over.into)}'s, the next. Move {them} there in this chunk, with `~/.claude/bin/todo-item` where it moves this plan's items, and say so in the chunk's opening line."]
|
||||
|
||||
|
||||
def joining_details(plan: Plan) -> list[str]:
|
||||
"""The detail of each of the first JOINING_DETAILS items that may join the chunk, in the table's order, and what the worker lacks: an item with no detail, or the items left out."""
|
||||
joining = bundle_candidates(plan.items, plan.first)
|
||||
|
||||
@@ -5,6 +5,7 @@ import typing
|
||||
|
||||
from failure import Failure
|
||||
from release_plan.todo_table import Item
|
||||
from release_plan.release import Release
|
||||
from release_plan.release_standing import LastCut
|
||||
from project_config import templates
|
||||
|
||||
@@ -20,6 +21,14 @@ class Ran:
|
||||
stderr: str
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class CarriedOver:
|
||||
"""The items, by ID in the plan's order, that the plan files under `cut`, a release already cut, and that count as `into`'s, the next release: release_standing.carried."""
|
||||
cut: Release
|
||||
into: Release
|
||||
ids: tuple[int, ...]
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Plan:
|
||||
"""The default branch's plan items, each with its detail, and `first`: the item the next chunk takes first."""
|
||||
@@ -28,6 +37,8 @@ class Plan:
|
||||
# first's tagline and detail.
|
||||
text: str
|
||||
branch_template: str
|
||||
# The items of a release already cut, which `items` and `first` hold as the next release's; None where the plan files none under one.
|
||||
carried: CarriedOver | None = None
|
||||
|
||||
@property
|
||||
def branch(self) -> str:
|
||||
|
||||
@@ -13,7 +13,7 @@ from project_config.templates import BRANCH
|
||||
from chunk_preflight import choices
|
||||
from failure import Failure
|
||||
from chunk_preflight.choices import forge_of, worktree_add
|
||||
from chunk_preflight.gathered import Gathered, ItemFacts, NamedPath, NoItem, Ran, Worktree
|
||||
from chunk_preflight.gathered import CarriedOver, Gathered, ItemFacts, NamedPath, NoItem, Ran, Worktree
|
||||
from test_env import isolated_env
|
||||
from release_plan.release_standing import LastCut, UNSEEN_RELEASES
|
||||
from chunk_preflight.main import line_count, ran, seconds, TIMEOUT
|
||||
@@ -54,6 +54,8 @@ Change `src/app.py`'s `run` and the files under `src`, not `gone.py`.
|
||||
SHIPPED = TODO.replace("| 3 | 0.2.0 | | | **Do the next thing.** | 2 | 2 | 3 | 5 | 3 | 1 by 9 | 56.2 |\n", "").replace("| 7 | 0.2.0 | 3 |", "| 7 | 0.2.0 | |").replace("### 3. Do the next thing.", "### 7. Do the thing after.")
|
||||
# The plan once release 0.2.0 has shipped all its items: only release 0.3.0's item 9 is left.
|
||||
LATER = TODO[:TODO.index("| 5 |")] + "| 9 | 0.3.0 | | | **Do a later thing.** | 1 | 1 | 1 | 1 | 1 | 1 by 9 | 90.0 |\n"
|
||||
# Item 9's row, the only one under release 0.3.0.
|
||||
NINTH = "| 9 | 0.3.0 | | | **Do a later thing.** | 1 | 1 | 1 | 1 | 1 | 1 by 9 | 90.0 |\n"
|
||||
# An items table that holds no row.
|
||||
EMPTY = TODO[:TODO.index("| 5 |")]
|
||||
CHANGELOG = "# Changelog\n\n## Unreleased\n\n- One.\n - A nested line.\n- Two.\n\n## 0.1.0\n\n- Old.\n"
|
||||
@@ -576,8 +578,17 @@ class Plans(unittest.TestCase):
|
||||
def test_takes_the_earliest_release_where_no_earlier_one_was_named_since_the_last_cut(self):
|
||||
self.assertEqual(planned(LATER, LastCut("v0.1.0", "", 4, [LATER]), "origin/main", BRANCH).first.id, 9)
|
||||
|
||||
def test_counts_the_items_of_a_release_already_cut_as_the_next_releases_and_says_to_move_them(self):
|
||||
plan = planned(TODO, LastCut("v0.2.0", "", 4, []), "origin/main", BRANCH)
|
||||
self.assertEqual((plan.first.id, plan.first.release), (3, (0, 3, 0)))
|
||||
self.assertEqual({item.release for item in plan.items}, {(0, 3, 0)})
|
||||
self.assertEqual(plan.carried, CarriedOver((0, 2, 0), (0, 3, 0), (5, 3, 7, 8)))
|
||||
said = rendered(dataclasses.replace(item_facts(), plan=plan), LastCut("v0.2.0", "", 4, []))
|
||||
self.assertIn("- Items 5, 3, 7 and 8 are filed under release 0.2.0, which is cut, so they count as release 0.3.0's, the next. Move them there in this chunk, with `~/.claude/bin/todo-item` where it moves this plan's items, and say so in the chunk's opening line.", said)
|
||||
self.assertNotIn("which is cut", rendered(item_facts()))
|
||||
|
||||
def test_says_the_plan_files_items_under_a_release_already_cut(self):
|
||||
why = planned(TODO, LastCut("v0.2.0", "", 4, []), "origin/main", BRANCH).why
|
||||
why = planned(TODO.replace(NINTH, ""), LastCut("v0.2.0", "", 4, []), "origin/main", BRANCH).why
|
||||
self.assertIn("release 0.2.0", why)
|
||||
self.assertIn("v0.2.0", why)
|
||||
self.assertIn("not after", why)
|
||||
|
||||
@@ -156,18 +156,30 @@ def todos_since(tag: str | None | Failure, ref: str, plan: str | None, cwd: str,
|
||||
def chunk_item(found: list[Item], cut: LastCut) -> Pick:
|
||||
"""The pick from todo.md's items, weighed against the last cut. Routing and chunk-preflight both pick with it, so they name one item."""
|
||||
upcoming = next_release(found, cut)
|
||||
return standing(upcoming, next_item(found), cut.reviewed) if isinstance(upcoming, Upcoming) else upcoming
|
||||
return standing(upcoming, next_item(carried(found, cut)), cut.reviewed) if isinstance(upcoming, Upcoming) else upcoming
|
||||
|
||||
|
||||
def carried(found: list[Item], cut: LastCut) -> list[Item]:
|
||||
"""found, with each item filed under the last cut's version or earlier filed under the next release instead: the earliest the plan names after the cut.
|
||||
|
||||
Someone cut a release while it held those items, and the loop works on: lilleman's call, 2026-11-16. found itself where nothing is cut, where no item is so filed, and where the plan names no release after the cut, since naming one is the human's.
|
||||
"""
|
||||
version = cut_version(cut)
|
||||
later = min((item.release for item in found if version is not None and item.release > version), default=None)
|
||||
if version is None or later is None or all(item.release > version for item in found):
|
||||
return found
|
||||
return [dataclasses.replace(item, release=max(item.release, later)) for item in found]
|
||||
|
||||
|
||||
def next_release(found: list[Item], cut: LastCut) -> Upcoming | Cut | Unknown:
|
||||
"""The next release after cut, and whether work has landed towards it. found holds the plan's items.
|
||||
|
||||
Cut where the plan files items under the last cut's version or earlier, and Unknown where the tags, or todo.md's texts since the cut, cannot be read.
|
||||
Cut where the plan files items under the last cut's version or earlier and names no later release for carried to file them under, and Unknown where the tags, or todo.md's texts since the cut, cannot be read.
|
||||
Where the branch has no tag, todos_since holds every version of todo.md, so a release todo.md named whose items are all done still reads as the next release.
|
||||
"""
|
||||
if isinstance(cut.tag, Failure):
|
||||
return Unknown()
|
||||
earliest = min((item.release for item in found), default=None)
|
||||
earliest = min((item.release for item in carried(found, cut)), default=None)
|
||||
version = cut_version(cut)
|
||||
if version is None:
|
||||
return Upcoming(earliest, True, has_unreleased(cut))
|
||||
|
||||
@@ -77,6 +77,26 @@ class NextRelease(unittest.TestCase):
|
||||
self.assertEqual(release_standing.next_release([one((1, 3, 0))], cut(Failure("count unreadable"))), release_standing.Upcoming((1, 3, 0), True, Failure("count unreadable")))
|
||||
|
||||
|
||||
class Carried(unittest.TestCase):
|
||||
def test_files_each_item_of_a_release_already_cut_under_the_earliest_release_the_plan_names_after_the_cut(self):
|
||||
held = [dataclasses.replace(one((1, 2, 3)), id=1), dataclasses.replace(one((1, 2, 0)), id=2), dataclasses.replace(one((1, 4, 0)), id=3), dataclasses.replace(one((1, 3, 0)), id=4)]
|
||||
carried = release_standing.carried(held, release_standing.LastCut("v1.2.3", "", 4, []))
|
||||
self.assertEqual([(item.id, item.release) for item in carried], [(1, (1, 3, 0)), (2, (1, 3, 0)), (3, (1, 4, 0)), (4, (1, 3, 0))])
|
||||
|
||||
def test_leaves_the_plan_as_it_is_where_nothing_is_cut_or_it_names_no_release_after_the_cut(self):
|
||||
held = [one((1, 2, 3))]
|
||||
for tag in ("v1.2.3", "v1.2.2", None, Failure("tags unreadable")):
|
||||
with self.subTest(tag=tag):
|
||||
self.assertIs(release_standing.carried(held, release_standing.LastCut(tag, "", 4, [])), held)
|
||||
|
||||
def test_takes_the_cut_releases_item_first_as_the_next_releases(self):
|
||||
held = [dataclasses.replace(one((1, 2, 3)), id=1), dataclasses.replace(one((1, 3, 0)), id=2)]
|
||||
cut = release_standing.LastCut("v1.2.3", "", 4, [])
|
||||
self.assertEqual(release_standing.chunk_item(held, cut), release_standing.Next((1, 3, 0), dataclasses.replace(held[0], release=(1, 3, 0))))
|
||||
self.assertEqual(release_standing.next_release(held, cut), release_standing.Upcoming((1, 3, 0), True, True))
|
||||
self.assertEqual(release_standing.next_release(held[:1], cut), release_standing.Cut((1, 2, 3)))
|
||||
|
||||
|
||||
class ChunkItem(unittest.TestCase):
|
||||
def test_takes_the_earliest_release_where_it_is_the_next_and_else_says_whether_the_next_is_ready_to_cut_or_to_plan(self):
|
||||
cases = (
|
||||
|
||||
Reference in New Issue
Block a user