Read a project's language, title templates and branch template from its config
This commit is contained in:
@@ -2,6 +2,7 @@ import dataclasses
|
||||
import re
|
||||
import typing
|
||||
|
||||
from project_config import templates
|
||||
from failure import Failure
|
||||
from review_rules.comprehension_history import HISTORY
|
||||
from release_plan.todo_table import Item, items
|
||||
@@ -58,9 +59,9 @@ class Branch:
|
||||
owner: dict[str, int]
|
||||
|
||||
|
||||
def cut_branch(log: str) -> Branch | Failure:
|
||||
def cut_branch(log: str, template: str = templates.TITLE) -> Branch | Failure:
|
||||
"""The branch LOG printed, cut into chunks as chunk_log cuts its first-parent line; a commit belongs to the oldest chunk whose commits reach it."""
|
||||
commits = parsed(log)
|
||||
commits = parsed(log, template)
|
||||
if isinstance(commits, Failure):
|
||||
return commits
|
||||
if not commits:
|
||||
@@ -87,8 +88,8 @@ def cut_branch(log: str) -> Branch | Failure:
|
||||
return Branch(commits, spans, owner)
|
||||
|
||||
|
||||
def parsed(log: str) -> dict[str, Commit] | Failure:
|
||||
"""Each commit LOG printed, by hash, in the order it printed them."""
|
||||
def parsed(log: str, template: str) -> dict[str, Commit] | Failure:
|
||||
"""Each commit LOG printed, by hash, in the order it printed them, its title read as its summary in template, the project's `commit-title`. So a round title or a `Drop item` title reads the same in every project."""
|
||||
commits = {}
|
||||
for record in log.split("\x00")[1:]:
|
||||
found = LOG_RECORD.fullmatch(record)
|
||||
@@ -96,7 +97,7 @@ def parsed(log: str) -> dict[str, Commit] | Failure:
|
||||
return Failure(f"git log printed a commit it could not read: {record[:200]!r}")
|
||||
full, committed, authored, parents, short, rest = found.groups()
|
||||
title, *files = rest.split("\n")
|
||||
commits[full] = Commit(full, short, int(committed), int(authored), tuple(parents.split()), title, tuple(name for name in files if name))
|
||||
commits[full] = Commit(full, short, int(committed), int(authored), tuple(parents.split()), templates.summary_of(template, title), tuple(name for name in files if name))
|
||||
return commits
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user