Exit when loop-claude is started outside a checkout
This commit is contained in:
+4
-2
@@ -10,7 +10,7 @@ interrupt: `claude --resume` on the terminal. An unfinished chunk resumes the sa
|
||||
cycle; a finished one starts a fresh session. Cycles continue until that interrupt or Ctrl-C. Words:
|
||||
~/.claude/CLAUDE.md → "Vocabulary".
|
||||
|
||||
Exit 1: no task, no premises, claude leaves no transcript, or the worker or the judge fails three
|
||||
Exit 1: no task, not inside a checkout, no premises, claude leaves no transcript, or the worker or the judge fails three
|
||||
times running, a verdict missing a field or quoting nothing in the transcript being a judge failure.
|
||||
Exit 2: the human is needed and stdin or stdout is not a terminal, or the interrupt ended without
|
||||
them typing anything. Rerunning resumes the session after either exit. Before an interrupt every
|
||||
@@ -115,7 +115,9 @@ def read_premises():
|
||||
|
||||
def checkout_root():
|
||||
found = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True)
|
||||
return found.stdout.strip() if found.returncode == 0 else os.getcwd()
|
||||
if found.returncode != 0:
|
||||
sys.exit(found.stderr.strip())
|
||||
return found.stdout.strip()
|
||||
|
||||
|
||||
def project():
|
||||
|
||||
@@ -86,10 +86,12 @@ class HumanTurns(unittest.TestCase):
|
||||
|
||||
|
||||
class CheckoutRoot(unittest.TestCase):
|
||||
def test_is_the_checkout_from_any_directory_inside_it_and_the_directory_itself_outside_one(self):
|
||||
def test_is_the_checkout_from_any_directory_inside_it_and_exits_outside_one(self):
|
||||
with tempfile.TemporaryDirectory() as tmp, contextlib.chdir(tmp):
|
||||
root = os.getcwd()
|
||||
self.assertEqual(loop.checkout_root(), root)
|
||||
with self.assertRaises(SystemExit) as stopped:
|
||||
loop.checkout_root()
|
||||
self.assertIn("not a git repository", stopped.exception.code)
|
||||
subprocess.run(["git", "init", "-q"], check=True)
|
||||
os.makedirs("a/b")
|
||||
with contextlib.chdir("a/b"):
|
||||
|
||||
Reference in New Issue
Block a user