Answer stability round 1: 1 🔴, 3 🟡; read chunks by one pure function, and skip chunks that never changed todo.md
This commit is contained in:
+20
-15
@@ -7,8 +7,8 @@ that remote, and reads origin's default branch, or else the local main or master
|
||||
reads origin as last fetched and says so on stderr.
|
||||
|
||||
Git history is the record. The default branch's first-parent line is cut into chunks by one rule: a
|
||||
merge commit is a chunk of its own, and any other commit joins the commit above it when both share a
|
||||
commit time, else starts a chunk. A chunk whose change removed items from todo.md, and changed more
|
||||
merge commit is a chunk of its own, and any other commit joins the run of the newer commit above it when
|
||||
both share a commit time, else starts a chunk. A chunk whose change removed items from todo.md, and changed more
|
||||
than todo.md and the records below, shipped those items. Each item's guess is the scores it held in
|
||||
the todo.md the chunk started from: L, E, I, R and S. An item scored before L, E and I replaced C
|
||||
holds R and S, and C too where its table also had A, G and Goals. The chunk measures:
|
||||
@@ -26,7 +26,7 @@ A chunk is marked `by rebase` where a commit in it has a committer time apart fr
|
||||
since a rebase replays a pull request's commits at once, and `never replayed` where none does, since
|
||||
a pushed or fast-forwarded commit may be part of a pull request. A merge's titles are its branch's
|
||||
commits'; any other chunk's are its own. Two pull requests merged in the same second read as one
|
||||
chunk. Rebase drops a round's commit that changed no file, so such a chunk gives its rounds and
|
||||
chunk. Rebase drops a round's commit that changed no file, so a rebase or push chunk gives its rounds and
|
||||
findings as lower bounds, `at least`, and the report ends saying all this.
|
||||
|
||||
Given L, E and I, on the levels ~/.claude/rules/todo-items.md defines, and S, it works out R from
|
||||
@@ -58,7 +58,7 @@ import sys
|
||||
from score_outcomes.anchors import anchor_lines, Anchors, ANCHORS_PATH, parse_anchors
|
||||
from git_repo import default_branch, file_at, full_history, git, top
|
||||
from failure import Failure
|
||||
from score_outcomes.outcomes import Landing, nearest, Outcome, outcomes_of, render, report, shipped
|
||||
from score_outcomes.outcomes import Chunk, Landing, nearest, Outcome, outcomes_of, render, report, shipped
|
||||
from todo_table import LEVELS, risk, TOP_SCORE
|
||||
from markdown_text import listed
|
||||
from utc_stamp import utc
|
||||
@@ -134,11 +134,19 @@ def read_outcomes(default: str) -> list[Outcome] | Failure:
|
||||
"""What each chunk on the default branch's first-parent line measured."""
|
||||
if partial := full_history():
|
||||
return partial
|
||||
chunks = read_chunks(default)
|
||||
if isinstance(chunks, Failure):
|
||||
return chunks
|
||||
log = git("log", "--first-parent", "--format=%x1e%h %ct %at %p", "--name-only", default)
|
||||
if isinstance(log, Failure):
|
||||
return log
|
||||
# Each record is a commit's line, then the files it changed against its first parent.
|
||||
records = [record.splitlines() for record in log.split("\x1e")[1:]]
|
||||
headers = [record[0] for record in records]
|
||||
hashes = [header.split()[0] for header in headers]
|
||||
plan = {short for short, record in zip(hashes, records) if "todo.md" in record}
|
||||
outcomes: list[Outcome] = []
|
||||
for first, last, committed, landed in chunks:
|
||||
for first, last, committed, landed in chunk_log(headers):
|
||||
# Only a chunk that changed todo.md can ship an item, so the others skip measure's git calls.
|
||||
if not any(short in plan for short in hashes[hashes.index(last):hashes.index(first) + 1]):
|
||||
continue
|
||||
label = first if first == last else f"{first}^..{last}"
|
||||
titled = f"{first}^1..{first}^2" if landed == "merge" else f"{first}^1..{last}"
|
||||
measured = measure(f"{first}^1", last, label, utc(committed), titled, landed)
|
||||
@@ -148,14 +156,11 @@ def read_outcomes(default: str) -> list[Outcome] | Failure:
|
||||
return outcomes
|
||||
|
||||
|
||||
def read_chunks(default: str) -> list[tuple[str, str, int, Landing]] | Failure:
|
||||
"""Each chunk on the default branch's first-parent line, newest first: its first and last commit as short hashes, its commit time, and how it reached the branch. A merge commit is a chunk of its own; any other commit joins the commit above it when both share a commit time."""
|
||||
log = git("log", "--first-parent", "--format=%h %ct %at %p", default)
|
||||
if isinstance(log, Failure):
|
||||
return log
|
||||
chunks: list[tuple[str, str, int, Landing]] = []
|
||||
def chunk_log(lines: list[str]) -> list[Chunk]:
|
||||
"""The chunks `git log --first-parent --format=%h %ct %at %p` lines cut, newest first: each chunk's first and last commit as short hashes, its commit time, and how it reached the branch. A merge commit is a chunk of its own; any other commit joins the run of the newer commit above it when both share a commit time."""
|
||||
chunks: list[Chunk] = []
|
||||
joinable = False
|
||||
for line in log.splitlines():
|
||||
for line in lines:
|
||||
short, committed, authored, *parents = line.split()
|
||||
if len(parents) > 1:
|
||||
chunks.append((short, short, int(committed), "merge"))
|
||||
|
||||
Reference in New Issue
Block a user