178def _status_changes(repo_root: Path, sha: str, source_rel: str) -> tuple[StatusChange, ...]:
179 """Diff the before/after status maps of every status-bearing path in ``sha``."""
181 changes: list[StatusChange] = []
185 for record_id, to_status
in sorted(after.items()):
186 if before.get(record_id) == to_status:
191 from_status=before.get(record_id),
196 return tuple(changes)
200 repo_root: Path, sha: str, prefix: str, added: tuple[str, ...]
202 """The prose of each record ``sha`` added, as written in that commit."""
204 bodies: dict[str, str] = {}
206 text =
_blob(repo_root, sha, prefix + rel)
210 _frontmatter, body = split_record_text(text)
218 repo_root: str | Path,
220 source_rel: str =
"oc_chat/oc_chat/roadmap/source",
221 since: str |
None =
None,
222) -> tuple[CommitRecord, ...]:
223 """Read the commits that added changelog records, newest first.
225 ``since`` is passed straight to ``git log --since`` (any git date spec).
226 Only commits that added at least one ``changelog/**`` record are returned:
227 those are the commits that make a claim, and the check has nothing to say
231 func =
"read_history"
232 root = Path(repo_root)
237 f
"--format={_RECORD_SEP}%H{_FIELD_SEP}%ad{_FIELD_SEP}%s",
241 args.append(f
"--since={since}")
242 args += [
"--", f
"{source_rel}/{CHANGELOG_DIR}"]
243 output =
_git(root, *args)
245 commits: list[CommitRecord] = []
246 prefix = f
"{source_rel}/"
247 for block
in output.split(_RECORD_SEP):
248 if not block.strip():
250 head, _, rest = block.partition(
"\n")
251 parts = head.split(_FIELD_SEP)
254 sha, date, subject = parts
256 line.strip()[len(prefix):]
257 for line
in rest.splitlines()
258 if line.strip().startswith(prefix)
267 added_changelog=added,
272 _dbg(
"OC_CHAT.MAIN", func, f
"read {len(commits)} claim-bearing commits", 2)
273 return tuple(commits)
frozenset[str] moved_ids(self)
str|None _blob(Path repo_root, str revision, str path)
dict[str, str] status_map(str|None text)
dict[str, str] _added_bodies(Path repo_root, str sha, str prefix, tuple[str,...] added)
str _git(Path repo_root, *str args)
tuple[StatusChange,...] _status_changes(Path repo_root, str sha, str source_rel)
list[str] _changed_status_paths(Path repo_root, str sha, str source_rel)
tuple[CommitRecord,...] read_history(str|Path repo_root, *, str source_rel="oc_chat/oc_chat/roadmap/source", str|None since=None)