aboutsummaryrefslogtreecommitdiffziptar.gz
path: root/tests/test_split.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_split.py')
-rw-r--r--tests/test_split.py30
1 files changed, 30 insertions, 0 deletions
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")