Answer architecture round 3: 0 🔴, 2 🟡 (0 misread); a record write names its version, even None, in every backend, and the unreleased section is read through markdown_text.section by one title pattern

This commit is contained in:
2026-11-16 16:17:12 +01:00
parent 50ce373c40
commit a7a6640ea1
12 changed files with 30 additions and 31 deletions
+5 -9
View File
@@ -1,15 +1,14 @@
"""How the plan stands to the last release cut: the next release, whether work has landed towards it, and whether it is to be planned, reviewed or cut; and, from that standing, the item the next chunk takes first, with what the default branch holds for the pick."""
import dataclasses
import re
from git_cli.git_repo import commits_since, file_at, git, Git
from plan.release import dated, dated_heading_pattern, newest_tag, parsed, Release, tagged, UNRELEASED_HEADING
from plan.release import dated, dated_heading_pattern, newest_tag, parsed, Release, tagged, UNRELEASED_TITLE
from failure import Failure
from plan.todo_table import Item, items, next_item, renames
from plan_store.plans import Plan
from plan_store import stores as plan_stores, plans
from project_config.settings import ProjectConfig
from text_files.markdown_text import sections
from text_files.markdown_text import section, sections
from record_store import stores
from project_config import templates
@@ -259,12 +258,9 @@ def unreleased_changes(cut: LastCut) -> int | Failure:
def unreleased_entries(changelog: str) -> int | None:
"""How many top-level `- ` entries CHANGELOG.md holds under its unreleased section, as UNRELEASED_HEADING heads it; None without that section."""
heading = UNRELEASED_HEADING.search(changelog)
if heading is None:
return None
body = re.split(r"^## ", changelog[heading.end():], maxsplit=1, flags=re.M)[0]
return sum(line.startswith("- ") for line in body.splitlines())
"""How many top-level `- ` entries CHANGELOG.md holds under its unreleased section, whose heading's title UNRELEASED_TITLE matches; None without that section."""
body = section(changelog, UNRELEASED_TITLE)
return None if body is None else sum(line.startswith("- ") for line in body)
def named_releases(todos: list[str] | Failure) -> set[Release] | Failure:
@@ -352,6 +352,8 @@ class ChunkItem(unittest.TestCase):
self.assertEqual(release_standing.unreleased_entries("# Changelog\n\n## Unreleased\n\n- One.\n - A nested line.\n- Two.\n\n## 0.1.0\n\n- Old.\n"), 2)
self.assertEqual(release_standing.unreleased_entries("# Changelog\n\n## Unreleased\n\n## 0.1.0\n\n- Old.\n"), 0)
self.assertIsNone(release_standing.unreleased_entries("# Changelog\n\n## 0.1.0\n\n- Old.\n"))
# A heading inside a code fence doesn't end the section.
self.assertEqual(release_standing.unreleased_entries("# Changelog\n\n## Unreleased\n\n- One.\n\n```\n## 0.1.0\n```\n\n- Two.\n\n## 0.1.0\n\n- Old.\n"), 2)
# The section todo-item finish files a bullet under, as a project's own changelog may head it.
self.assertEqual(release_standing.unreleased_entries("# Changelog\n\n## 0.6.0 (unreleased)\n\n- One.\n\n## 0.5.0\n\n- Old.\n"), 1)