This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""Move the clone this tool ships in to the setup's newest release.
|
||||
|
||||
usage: self-update
|
||||
|
||||
Run it by its path in a clone of a release, as in ~/.claude/bin/self-update. It fetches origin's
|
||||
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 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.
|
||||
|
||||
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
|
||||
the move would drop work no release holds. Untracked files, such as Claude Code's sessions and
|
||||
memory, stay as they are.
|
||||
"""
|
||||
import sys
|
||||
|
||||
from failure import Failure
|
||||
from loop_state.paths import RELEASE_ROOT
|
||||
from self_update.move import moved_to_newest
|
||||
|
||||
|
||||
def main(argv: list[str], clone: str = str(RELEASE_ROOT)) -> int:
|
||||
"""Move clone, which is the clone this tool ships in unless a test names another."""
|
||||
if argv[:1] in (["-h"], ["--help"]):
|
||||
print(__doc__.strip())
|
||||
return 0
|
||||
if argv:
|
||||
print("self-update: usage: self-update", file=sys.stderr)
|
||||
return 1
|
||||
moved = moved_to_newest(clone)
|
||||
if isinstance(moved, Failure):
|
||||
print(f"self-update: {moved.reason}", file=sys.stderr)
|
||||
return 1
|
||||
print(moved)
|
||||
return 0
|
||||
Reference in New Issue
Block a user