Name the loop's states with one transition function, and inject its side effects
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import subprocess
|
||||
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.outcome import Stop
|
||||
|
||||
|
||||
def checkout_root(cwd) -> str | Stop:
|
||||
def checkout_root(cwd, effects: Effects) -> str | Stop:
|
||||
try:
|
||||
found = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output=True, cwd=cwd, text=True)
|
||||
found = effects.run(["git", "rev-parse", "--show-toplevel"], capture_output=True, cwd=cwd, text=True)
|
||||
except OSError as failure:
|
||||
return Stop(1, f"could not start git: {failure.strerror}")
|
||||
if found.returncode != 0:
|
||||
@@ -13,10 +12,10 @@ def checkout_root(cwd) -> str | Stop:
|
||||
return found.stdout.strip()
|
||||
|
||||
|
||||
def checkouts(root) -> list[str]:
|
||||
def checkouts(root, effects: Effects) -> list[str]:
|
||||
found = [root]
|
||||
try:
|
||||
listing = subprocess.run(["git", "worktree", "list", "--porcelain"], capture_output=True, cwd=root, text=True)
|
||||
listing = effects.run(["git", "worktree", "list", "--porcelain"], capture_output=True, cwd=root, text=True)
|
||||
except OSError:
|
||||
return found
|
||||
if listing.returncode == 0:
|
||||
|
||||
Reference in New Issue
Block a user