Run every claude the loop starts in a Claude home generated outside the clone
CI / tests (pull_request) Successful in 4m45s

This commit is contained in:
2026-12-04 01:07:03 +01:00
parent 2460b9e132
commit 0203a8e0b3
48 changed files with 703 additions and 369 deletions
+3 -5
View File
@@ -6,13 +6,11 @@ Run it by its path in a clone of a release, as in <clone>/bin/self-update. It fe
tags and checks out the newest v* tag, detached, so the clone holds only what a release holds.
Development happens in another clone, such as ~/code/claude-config. It prints the clone and the version it moved
from and to, then CHANGELOG.md's section for each version since, so you can do what each asks, such
as a new step under Install. Where the move changed settings.json, it asks you to pick the model
again with /model, since git's clean filter keeps the model out of every commit.
as a new step under Install.
It refuses, exit 1, and leaves the clone as it was where a file the clone tracks has an
uncommitted change the newest tag doesn't hold: such as a hook Claude Code wrote into settings.json.
Merge the change through the development clone and cut a release first. A model picked with /model
is no such change. It also refuses where the newest tag doesn't hold the clone's commit, since
uncommitted change the newest tag doesn't hold. Merge the change through the development clone
and cut a release first. It also refuses where the newest tag doesn't hold the clone's commit, since
the move would drop work no release holds. Untracked files, such as Claude Code's sessions and
memory, stay as they are.
"""
+2 -13
View File
@@ -15,9 +15,6 @@ def moved_to_newest(clone: str) -> str | Failure:
return tag
if tag is None:
return Failure(f"{clone}'s origin has no v* tag to move to")
# Re-reads each file through the clean filter, so a model pick alone leaves settings.json unchanged.
if isinstance(refreshed := git("update-index", "-q", "--refresh", cwd=clone), Failure):
return refreshed
listed = git("diff", "--name-only", "-z", "HEAD", cwd=clone)
if isinstance(listed, Failure):
return listed
@@ -34,15 +31,9 @@ def moved_to_newest(clone: str) -> str | Failure:
return f"{clone} is already on {tag}, the newest release."
if isinstance(git("merge-base", "--is-ancestor", "HEAD", tag, cwd=clone), Failure):
return Failure(f"{tag} doesn't hold {clone}'s commit, so the move would drop work no release holds: cut a release that holds it first")
settings_changed = isinstance(git("diff", "--quiet", "HEAD", tag, "--", "settings.json", cwd=clone), Failure)
# The tag holds each uncommitted change, so undoing them doesn't lose anything, and lets the move below take the tag's copy.
# A settings.json the clean filter shows unchanged may still differ on disk, by a model pick or Claude Code's key order, which checkout refuses to overwrite; the pick is asked for again below.
tracked = git("ls-files", "-z", "--", "settings.json", cwd=clone)
if isinstance(tracked, Failure):
return tracked
set_aside = sorted({*changed, *names(tracked)} if settings_changed else set(changed))
if set_aside:
restored = git("checkout", "--quiet", "HEAD", "--", *set_aside, cwd=clone)
if changed:
restored = git("checkout", "--quiet", "HEAD", "--", *changed, cwd=clone)
if isinstance(restored, Failure):
return restored
moved = git("checkout", "--quiet", "--detach", tag, cwd=clone)
@@ -50,8 +41,6 @@ def moved_to_newest(clone: str) -> str | Failure:
return moved
changelog = git("show", f"{tag}:CHANGELOG.md", cwd=clone)
lines = [f"Moved {clone} from {old_tag or 'an untagged commit'} to {tag}."]
if settings_changed:
lines.append("settings.json changed: pick the model again with /model.")
if not isinstance(changelog, Failure):
lines += newer_sections(changelog, old_tag)
return "\n\n".join(lines)
+1 -35
View File
@@ -77,9 +77,8 @@ class SelfUpdate(unittest.TestCase):
self.assertIn("## 0.2.0\n\n- Second.", ran.stdout)
self.assertNotIn("First.", ran.stdout)
self.assertNotIn("Later.", ran.stdout)
self.assertNotIn("/model", ran.stdout)
def test_stops_with_gits_error_where_the_index_cannot_be_refreshed(self):
def test_stops_with_gits_error_where_the_index_cannot_be_read(self):
self.release("0.2.0", "- Second.\n", '{"theme": "dark"}\n')
(self.target / ".git" / "index").write_bytes(b"DIRC")
ran = self.update()
@@ -132,36 +131,3 @@ class SelfUpdate(unittest.TestCase):
self.assertEqual(ran.returncode, 1)
self.assertIn(f"v0.1.0 doesn't hold {self.target}'s commit", ran.stderr)
self.assertEqual(self.git(self.target, "branch", "--show-current").strip(), "main")
def test_takes_a_model_picked_with_the_clean_filter_set_as_no_change(self):
self.release("0.2.0", "- Second.\n", '{\n "theme": "dark"\n}\n')
self.git(self.target, "fetch", "-q", "--tags", "origin")
self.git(self.target, "checkout", "-q", "--detach", "v0.2.0")
(self.target / ".gitattributes").write_text("/settings.json filter=settings\n")
self.git(self.target, "config", "filter.settings.clean", f"{sys.executable} {BIN / 'settings_filter.py'}")
(self.target / "settings.json").write_text('{"model": "claude-opus-5-5", "theme": "dark"}\n')
self.release("0.3.0", "- Third.\n", '{\n "theme": "dark"\n}\n')
ran = self.update()
self.assertEqual(ran.returncode, 0, ran.stderr)
self.assertEqual(self.head(), "v0.3.0")
self.assertIn('"model"', (self.target / "settings.json").read_text(), "a release that leaves settings.json as it was keeps the pick")
def test_moves_a_settings_json_that_differs_only_by_a_model_pick_and_key_order_where_the_release_changes_it(self):
self.release("0.2.0", "- Second.\n", '{\n "permissions": {},\n "theme": "dark"\n}\n')
self.git(self.target, "fetch", "-q", "--tags", "origin")
self.git(self.target, "checkout", "-q", "--detach", "v0.2.0")
(self.target / ".gitattributes").write_text("/settings.json filter=settings\n")
self.git(self.target, "config", "filter.settings.clean", f"{sys.executable} {BIN / 'settings_filter.py'}")
(self.target / "settings.json").write_text('{\n "theme": "dark",\n "model": "opus",\n "permissions": {}\n}\n')
self.release("0.3.0", "- Third.\n", '{\n "permissions": {},\n "theme": "light"\n}\n')
ran = self.update()
self.assertEqual(ran.returncode, 0, ran.stderr)
self.assertEqual(self.head(), "v0.3.0")
self.assertEqual((self.target / "settings.json").read_text(), '{\n "permissions": {},\n "theme": "light"\n}\n')
self.assertIn("settings.json changed: pick the model again with /model.", ran.stdout)
def test_asks_for_the_model_again_where_the_release_changes_settings_json(self):
self.release("0.2.0", "- Second.\n", '{"theme": "light"}\n')
ran = self.update()
self.assertEqual(ran.returncode, 0, ran.stderr)
self.assertIn("settings.json changed: pick the model again with /model.", ran.stdout)