Carry the edits the first commit left unstaged
CI / tests (pull_request) Has been cancelled

This commit is contained in:
2026-12-03 23:52:10 +01:00
parent 3b07c05eba
commit f3f9c91348
19 changed files with 366 additions and 332 deletions
+7 -24
View File
@@ -1,4 +1,4 @@
"""`deploy-release --cut`: cut the next release once it is ready, through a pull request, then tag it and move ~/.claude to it.
"""`cut-release`: cut the next release once it is ready, through a pull request, then tag it.
Each step first checks whether an earlier run did it, so a rerun continues where the last run stopped.
"""
@@ -12,15 +12,14 @@ import typing
from release_plan.release_standing import chunk_item, Cut, default_plan, Next, ReadyToCut, ReviewDue, Unplanned
from project_config.settings import DEFAULT_FLOOR
from git_cli.git_repo import default_ref, git
from deploy_release.deploy import deploy
from failure import Failure
from plan_store.todo_md import FilePlan
from record_store.stores import FileStore
from forge.commands import forge_of, runner
from plan.release import newest_tag, Release, REVIEW_TITLE, tagged, UNRELEASED_HEADING, version
from forge import pulls
from deploy_release import release_pull
from deploy_release.trace import Say
from cut_release import release_pull
from cut_release.trace import Say
from project_config import templates
@@ -35,10 +34,8 @@ class Ready:
reviewed: bool
def cut(clone: str, checkout: str, sleep: typing.Callable[[float], None], say: Say) -> str | Failure:
def cut(clone: str, sleep: typing.Callable[[float], None], say: Say) -> str | Failure:
"""What the cut did, as the tool prints it; a Failure with git's, the forge's or the tool's reason where a step stopped. say takes each step as it finishes."""
if isinstance(same := same_origin(clone, checkout), Failure):
return same
if isinstance(fetched := git("fetch", "--quiet", "--tags", "origin", cwd=clone), Failure):
return fetched
if isinstance(dropped := drop_unpushed_cut_tags(clone), Failure):
@@ -78,10 +75,7 @@ def cut(clone: str, checkout: str, sleep: typing.Callable[[float], None], say: S
return pushed
say(f"pushed the tag {tag}")
delete_release_branch(clone, branch, say)
moved = deploy(checkout)
if isinstance(moved, Failure):
return Failure(f"cut and pushed {tag}, but moving {checkout} stopped: {moved.reason}. Fix that, then run a bare deploy-release.")
return f"{moved}\n\nDone: {tag} is cut and pushed, and {checkout} is on it."
return f"Done: {tag} is cut and pushed. Each clone of a release takes it with its bin/self-update."
def patch_refusal(clone: str, ref: str, release: Release) -> Failure | None:
@@ -91,7 +85,7 @@ def patch_refusal(clone: str, ref: str, release: Release) -> Failure | None:
return tag
cut_release = tagged(tag)
if cut_release is not None and release[:2] == cut_release[:2]:
return Failure(f"{version(release)} is a patch of {tag}: cut it with --cut-patch <commits>, so it holds only the fix and not all of {ref}")
return Failure(f"{version(release)} is a patch of {tag}: cut it with --patch <commits>, so it holds only the fix and not all of {ref}")
return None
@@ -124,17 +118,6 @@ def drop_unpushed_cut_tags(clone: str) -> Failure | None:
return None
def same_origin(clone: str, checkout: str) -> Failure | None:
"""A Failure unless clone is a clone of the origin checkout takes its releases from, so a cut never cuts another project."""
urls = [git("ls-remote", "--get-url", "origin", cwd=where) for where in (clone, checkout)]
failed = next((url for url in urls if isinstance(url, Failure)), None)
if failed is not None:
return failed
if urls[0] != urls[1]:
return Failure(f"run deploy-release in a clone of {checkout}'s origin, {str(urls[1]).strip()}; this directory's origin is {str(urls[0]).strip()}")
return None
def clone_plan(clone: str) -> FilePlan:
"""The clone's plan, at the path this repo keeps it. ready_release only reads it; FilePlan also takes the files and the floor a write would rank it against, and the clone has no config to set the floor."""
goals, decisions, history = (FileStore(pathlib.Path(clone, path), path) for path in ("README.md", "docs/decisions.md", "docs/comprehension-history.md"))
@@ -264,7 +247,7 @@ def rewritten(file: pathlib.Path, doing: str, outcome: str, rewrite: typing.Call
@contextlib.contextmanager
def scratch_worktree(clone: str, at: str) -> typing.Iterator[pathlib.Path | Failure]:
"""A worktree of clone, detached at at, in a folder of its own that is removed afterwards, so the clone's checkout stays as it is; a Failure where git can't add it."""
worktree = pathlib.Path(tempfile.mkdtemp(prefix="deploy-release-")) / "worktree"
worktree = pathlib.Path(tempfile.mkdtemp(prefix="cut-release-")) / "worktree"
try:
added = git("worktree", "add", "--quiet", "--detach", str(worktree), at, cwd=clone)
yield added if isinstance(added, Failure) else worktree