Answer stability round 1: 1 🔴, 1 🟡 (0 misread); stamp deploy-release's trace in UTC, end a stopped run's trace, drop redundant assertions, and the product-owner and prose fixes
This commit is contained in:
+11
-11
@@ -142,7 +142,7 @@ def changelog_entries(clone: str, ref: str, commits: list[str]) -> list[str] | F
|
||||
if isinstance(changelog, Failure):
|
||||
return changelog
|
||||
unreleased = section(changelog, UNRELEASED_TITLE)
|
||||
# The merge-back finds the heading with unreleased_start, after the tag is pushed, so that is asked here too.
|
||||
# The merge-back finds the heading with unreleased_start only after the tag is pushed, so check it here first.
|
||||
if unreleased is None or unreleased_start(changelog.split("\n")) is None:
|
||||
return Failure(f"CHANGELOG.md on {ref} has no ## Unreleased section, which the patch's entries come from: add it on {ref}")
|
||||
entries = [line for line in unreleased if line in added]
|
||||
@@ -170,7 +170,7 @@ def tag_patch(clone: str, patch: Patch, say: Say, ci: Ci) -> Failure | None:
|
||||
if isinstance(applied := apply_commit(clone, worktree, commit, patch), Failure):
|
||||
return applied
|
||||
head = lambda changelog: headed("# Changelog\n" if changelog is None else changelog, patch.entries, patch.named)
|
||||
if isinstance(written := rewritten(worktree / "CHANGELOG.md", f"head CHANGELOG.md with ## {patch.named} in the patch's worktree, so nothing is tagged", head), Failure):
|
||||
if isinstance(written := rewritten(worktree / "CHANGELOG.md", f"head CHANGELOG.md with ## {patch.named} in the patch's worktree", "Nothing is tagged.", head), Failure):
|
||||
return written
|
||||
if isinstance(committed := git("commit", "--quiet", "--all", "--message", title, cwd=str(worktree)), Failure):
|
||||
return committed
|
||||
@@ -205,7 +205,7 @@ def apply_commit(clone: str, worktree: pathlib.Path, commit: str, patch: Patch)
|
||||
if not diff:
|
||||
return None
|
||||
patch_file = worktree.parent / "commit.patch"
|
||||
if isinstance(written := rewritten(patch_file, f"write {commit[:12]}'s changes to a file to apply, so nothing is tagged", lambda _: diff), Failure):
|
||||
if isinstance(written := rewritten(patch_file, f"write {commit[:12]}'s changes to a file to apply", "Nothing is tagged.", lambda _: diff), Failure):
|
||||
return written
|
||||
if isinstance(applied := git("apply", "--3way", "--index", str(patch_file), cwd=str(worktree)), Failure):
|
||||
subject = git("log", "-1", "--format=%s", commit, cwd=clone)
|
||||
@@ -224,7 +224,7 @@ def run_ci(worktree: pathlib.Path, ref: str, ci: Ci) -> Failure | None:
|
||||
return Failure("the patch holds no ci.sh to test it with")
|
||||
ran = ci(worktree)
|
||||
if isinstance(ran, Failure):
|
||||
return Failure(f"{ran.reason}, so nothing is tagged. Rerun once that is fixed.")
|
||||
return Failure(f"{ran.reason}. Nothing is tagged: rerun once ci.sh passes.")
|
||||
if ran.code == 0:
|
||||
return None
|
||||
tail = "\n".join(ran.output.strip().splitlines()[-30:])
|
||||
@@ -239,23 +239,23 @@ def push_merge_back(clone: str, patch: Patch, replacing: str | None) -> Failure
|
||||
if isinstance(merged := git("merge", "--quiet", "--no-ff", "--no-commit", "--strategy", "ours", f"v{patch.named}", cwd=str(worktree)), Failure):
|
||||
return merged
|
||||
# The tag is pushed by now, so each stop here says that a rerun with the same commits takes it and builds only this merge-back again.
|
||||
rerun = f"v{patch.named} is pushed, and a rerun with the same commits merges it back"
|
||||
rerun = f"v{patch.named} is pushed, and a rerun with the same commits merges it back."
|
||||
def move(changelog: str | None) -> str | Failure:
|
||||
moved = moved_entries(changelog or "", patch.entries, patch.named)
|
||||
return Failure(f"{moved.reason}, on {patch.ref}: add the heading there; {rerun}") if isinstance(moved, Failure) else moved
|
||||
if isinstance(written := rewritten(worktree / "CHANGELOG.md", f"move the entries of {patch.named} out of ## Unreleased in the merge-back's worktree; {rerun}", move), Failure):
|
||||
moved = moved_entries(changelog or "", patch.entries, patch.named, patch.ref)
|
||||
return Failure(f"{moved.reason}: add the heading there. {rerun}") if isinstance(moved, Failure) else moved
|
||||
if isinstance(written := rewritten(worktree / "CHANGELOG.md", f"move the entries of {patch.named} out of ## Unreleased in the merge-back's worktree", rerun, move), Failure):
|
||||
return written
|
||||
if isinstance(committed := git("commit", "--quiet", "--all", "--message", f"Merge release {patch.named} into main", cwd=str(worktree)), Failure):
|
||||
return committed
|
||||
return push_branch(worktree, f"release-{patch.named}", replacing)
|
||||
|
||||
|
||||
def moved_entries(changelog: str, entries: list[str], named: str) -> str | Failure:
|
||||
"""changelog with entries taken out of its ## Unreleased section and put in a ## named section right below that section; a Failure where it has no such heading."""
|
||||
def moved_entries(changelog: str, entries: list[str], named: str, ref: str) -> str | Failure:
|
||||
"""changelog, as ref holds it, with entries taken out of its ## Unreleased section and put in a ## named section right below that section; a Failure where it has no such heading."""
|
||||
lines = changelog.split("\n")
|
||||
start = unreleased_start(lines)
|
||||
if start is None:
|
||||
return Failure(f"CHANGELOG.md has no ## Unreleased heading to move the entries of {named} from")
|
||||
return Failure(f"CHANGELOG.md on {ref} has no ## Unreleased heading to move the entries of {named} from")
|
||||
end = next((index for index in range(start + 1, len(lines)) if lines[index].startswith("## ")), len(lines))
|
||||
kept = [line for line in lines[start + 1:end] if line not in entries]
|
||||
while kept and not kept[-1].strip():
|
||||
|
||||
Reference in New Issue
Block a user