From 6f559437fe95b3a952b63b6672db7d89d0ce86c2 Mon Sep 17 00:00:00 2001 From: godosa Date: Wed, 7 Oct 2026 09:57:12 +0200 Subject: wf start: refuse worktree of another repo; .wf-home not stray Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01JEAjUkQRrCYX5MZhWxdtj2 --- tests/test_split.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests') diff --git a/tests/test_split.py b/tests/test_split.py index 934bf6f..9d19308 100644 --- a/tests/test_split.py +++ b/tests/test_split.py @@ -91,6 +91,26 @@ class StartSplitTest(SplitCli): self.assertIn(f"cd {wt} && (make test) && ", out) self.assertFalse((self.root / ".worktrees").exists()) # nothing in the private repo + def test_start_refuses_private_repo_worktree(self): + wt = self.root / ".worktrees" / "slow" + git(self.root, "worktree", "add", "-q", str(wt), "-b", "slow/old") + code, out, err = self.wf("start", "t-three", "--worktree", str(wt), "--branch", "slow/t-three", + project=False, env=IDENT) + self.assertNotEqual(code, 0) + self.assertIn("is not a worktree of", err) + self.assertFalse((wt / ".wf-home").exists()) + self.assertEqual(subprocess.run(["git", "branch", "--show-current"], cwd=wt, capture_output=True, + text=True).stdout.strip(), "slow/old") # not switched + self.assertIn("- **t-three** [P2] (<1h): Third", (self.root / "TASKS.md").read_text()) # no progress + + def test_start_reuses_existing_code_worktree(self): + wt = self.code / ".worktrees" / "slow" + git(self.code, "worktree", "add", "-q", str(wt), "-b", "slow/old") + code, out, err = self.wf("start", "t-three", "--worktree", str(wt), "--branch", "slow/t-three", + project=False, env=IDENT) + self.assertEqual(code, 0, out + err) + self.assertEqual((wt / ".wf-home").read_text(), f"{self.root}\n") + def test_setup_in_code_worktree(self): wt = self.add_wt() code, out, err = self.wf("setup", project=False, cwd=wt) @@ -152,6 +172,16 @@ class FinishSplitTest(SplitCli): self.assertEqual(subprocess.run(["git", "branch", "--list", "sonnet/t-three"], cwd=self.code, capture_output=True, text=True).stdout, "") + def test_unignored_wf_home_does_not_block(self): + (self.code / ".gitignore").write_text(".worktrees/\n") + git(self.code, "commit", "-qam", "no wf-home ignore") + git(self.wt, "rebase", "-q", "master") + (self.wt / "code.txt").write_text("x\n") + code, out, err = self.finish("t-three", "-m", "ok", "--commit", "impl", "code.txt") + self.assertEqual(code, 0, out + err) + self.assertNotIn(".wf-home", subprocess.run(["git", "show", "--stat", "master"], cwd=self.code, + capture_output=True, text=True).stdout) + def test_stray_code_file_refused_task_open(self): (self.wt / "code.txt").write_text("x\n") (self.wt / "stray.txt").write_text("s\n") -- cgit