Files
claude-config/bin/loop_claude/checkout.py
T

23 lines
667 B
Python

import subprocess
from loop_claude.outcome import Stop
def checkout_root():
found = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True)
if found.returncode != 0:
return Stop(1, found.stderr.strip())
return found.stdout.strip()
def checkouts(root):
found = [root]
listing = subprocess.run(["git", "worktree", "list", "--porcelain"], capture_output=True, cwd=root, text=True)
if listing.returncode == 0:
found += [line.split(" ", 1)[1] for line in listing.stdout.splitlines() if line.startswith("worktree ")]
return sorted(set(found))
def project_name(root, code):
return root.removeprefix(f"{code}/").lstrip("/")