Read and write each record through the store its config names, and open one for agents with project-record
CI / tests (pull_request) Successful in 2m14s

This commit is contained in:
2026-11-13 23:54:04 +01:00
parent 854eb63407
commit 084bc74b1c
40 changed files with 624 additions and 161 deletions
+8 -7
View File
@@ -8,6 +8,7 @@ from failure import Failure
from release_plan.todo_table import Item, items, next_item, renames
from project_config.settings import Place
from text_files.markdown_text import sections
from record_store import stores
# The version a branch with no v* tag and no dated CHANGELOG.md heading counts as cut: below every release, 0.0.0 included, so that every release todo.md names comes after it.
BEFORE_FIRST_RELEASE = (-1, 0, 0)
@@ -94,10 +95,10 @@ class DefaultPlan:
cut: LastCut
def default_plan(root: str, ref: str, plan: Place, changelog: Place, run: Git = git) -> DefaultPlan:
"""What ref, the default branch as last fetched, holds for the pick, read in the checkout at root through run. plan and changelog are where the project's config puts todo.md and CHANGELOG.md."""
def default_plan(root: str, ref: str, plan: Place, changelog: stores.RecordStore, run: Git = git) -> DefaultPlan:
"""What ref, the default branch as last fetched, holds for the pick, read in the checkout at root through run. plan is where the project's config puts todo.md, and changelog the store it names for the changelog."""
tag = newest_tag(root, merged_into=ref, run=run)
changes = held_at(ref, changelog, root, run)
changes = stores.held_at(ref, changelog, root, run)
after = dated_cut(tag, changes)
since = tag if after is None else heading_commit(after, ref, changelog, root, run)
commits = since if isinstance(since, Failure) else commits_since(since, ref, root, run)
@@ -117,12 +118,12 @@ def held_at(revision: str, place: Place, cwd: str, run: Git = git) -> str | Fail
return Failure(f"cannot read {place}: {failure}")
def heading_commit(release: Release, ref: str, changelog: Place, cwd: str, run: Git = git) -> str | None | Failure:
"""The oldest commit on ref that added release's dated heading to CHANGELOG.md, which a branch with no tag counts the unreleased commits from; None where git finds none, as for a changelog outside the checkout."""
if isinstance(changelog, pathlib.Path):
def heading_commit(release: Release, ref: str, changelog: stores.RecordStore, cwd: str, run: Git = git) -> str | None | Failure:
"""The oldest commit on ref that added release's dated heading to the changelog, which a branch with no tag counts the unreleased commits from; None where git finds none, as for a changelog no commit holds."""
if changelog.tracked is None:
return None
# -G matches the heading line itself, so a changelog entry that quotes the heading doesn't count.
added = run("log", "--reverse", "--format=%H", "-G", dated_heading_pattern(release), ref, "--", changelog, cwd=cwd)
added = run("log", "--reverse", "--format=%H", "-G", dated_heading_pattern(release), ref, "--", changelog.tracked, cwd=cwd)
return added if isinstance(added, Failure) else next(iter(added.split()), None)