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
+11 -12
View File
@@ -39,6 +39,7 @@ from failure import Failure
from project_config.main import located
from release_plan import plan_file, ranking
from project_config.settings import ProjectConfig
from record_store.stores import store
# Each score flag, as --l or --L, and the column it fills.
LETTERS = ("L", "E", "I", "S")
@@ -118,14 +119,14 @@ def add(args: argparse.Namespace, config: ProjectConfig, stdin: typing.TextIO) -
def finish(args: argparse.Namespace, config: ProjectConfig) -> str | Failure:
todo, changelog = config.paths["plan"], config.paths["changelog"]
todo, changelog = config.paths["plan"], store(config, "changelog")
texts = finish_texts(args, config)
if isinstance(texts, Failure):
return Failure(f"not finished: {texts.reason}")
ranked, news = texts
if unwritten := plan_file.write(todo, ranked.text):
return Failure(f"not finished: {unwritten.reason}")
if news is not None and (unwritten := plan_file.write(changelog, news)):
if news is not None and (unwritten := changelog.write(news)):
return Failure(f"{unwritten.reason}; todo.md no longer holds item {args.id}, so add its bullet by hand")
for line in plan_file.report_lines(todo, ranked):
print(line, file=sys.stderr)
@@ -134,9 +135,12 @@ def finish(args: argparse.Namespace, config: ProjectConfig) -> str | Failure:
def finish_texts(args: argparse.Namespace, config: ProjectConfig) -> tuple[ranking.Ranked, str | None] | Failure:
"""What finish writes: the plan ranked without item args.id, and the changelog's new text, None where finish leaves it as is."""
todo, changelog = config.paths["plan"], config.paths["changelog"]
if changelog.exists() and args.changelog is None and not args.no_changelog:
return Failure(f"{changelog} exists; pass --changelog <bullet>, or --no-changelog where the repo doesn't publish anything")
todo, changelog = config.paths["plan"], store(config, "changelog")
news = changelog.read()
if isinstance(news, Failure):
return news
if news and args.changelog is None and not args.no_changelog:
return Failure(f"{changelog.label} exists; pass --changelog <bullet>, or --no-changelog where the repo doesn't publish anything")
texts = plan_file.read_all(todo, config)
if isinstance(texts, Failure):
return texts
@@ -148,11 +152,6 @@ def finish_texts(args: argparse.Namespace, config: ProjectConfig) -> tuple[ranki
return ranked
if args.changelog is None:
return ranked, None
try:
news = with_bullet(changelog.read_text(encoding="utf-8") if changelog.exists() else "", args.changelog)
except OSError as failure:
return Failure(f"{changelog}: {failure.strerror}")
except UnicodeDecodeError:
return Failure(f"{changelog}: not UTF-8")
return news if isinstance(news, Failure) else (ranked, news)
added = with_bullet(news, args.changelog)
return added if isinstance(added, Failure) else (ranked, added)