feat(kanban): configure worktree paths and branches

This commit is contained in:
aqilaziz
2026-05-16 05:41:11 +07:00
parent 7fee1f61eb
commit a7558cf27b
7 changed files with 163 additions and 22 deletions
+38 -1
View File
@@ -32,6 +32,7 @@ def kanban_home(tmp_path, monkeypatch):
[
("scratch", ("scratch", None)),
("worktree", ("worktree", None)),
("worktree:/tmp/wt", ("worktree", "/tmp/wt")),
("dir:/tmp/work", ("dir", "/tmp/work")),
],
)
@@ -45,8 +46,12 @@ def test_parse_workspace_flag_expands_user():
assert path.endswith("/vault")
assert not path.startswith("~")
kind, path = kc._parse_workspace_flag("worktree:~/trees/t6-wire")
assert kind == "worktree"
assert path.endswith("/trees/t6-wire")
assert not path.startswith("~")
@pytest.mark.parametrize("bad", ["cloud", "dir:", "", "worktree:/x"])
@pytest.mark.parametrize("bad", ["cloud", "dir:", "worktree:", ""])
def test_parse_workspace_flag_rejects(bad):
if not bad:
# Empty -> defaults; not an error.
@@ -56,6 +61,17 @@ def test_parse_workspace_flag_rejects(bad):
kc._parse_workspace_flag(bad)
def test_parse_branch_flag_rejects_empty_and_option_like():
assert kc._parse_branch_flag(None) is None
assert kc._parse_branch_flag(" wt/t6-wire ") == "wt/t6-wire"
with pytest.raises(argparse.ArgumentTypeError):
kc._parse_branch_flag(" ")
with pytest.raises(argparse.ArgumentTypeError):
kc._parse_branch_flag("-bad")
with pytest.raises(argparse.ArgumentTypeError):
kc._parse_branch_flag("bad branch")
# ---------------------------------------------------------------------------
# run_slash smoke tests (end-to-end via the same entry both CLI and gateway use)
# ---------------------------------------------------------------------------
@@ -74,6 +90,27 @@ def test_run_slash_create_and_list(kanban_home):
assert "alice" in out
def test_run_slash_create_worktree_path_and_branch(kanban_home, tmp_path):
target = tmp_path / ".worktrees" / "t6-wire"
target_arg = target.as_posix()
out = kc.run_slash(
f"create 'ship worktree' --workspace worktree:{target_arg} --branch wt/t6-wire"
)
assert "Created" in out
with kb.connect() as conn:
tasks = kb.list_tasks(conn)
task = tasks[0]
assert task.workspace_kind == "worktree"
assert task.workspace_path == target_arg
assert task.branch_name == "wt/t6-wire"
def test_run_slash_rejects_branch_without_worktree(kanban_home):
out = kc.run_slash("create 'bad branch' --workspace scratch --branch wt/bad")
assert "--branch is only valid with --workspace worktree" in out
def test_run_slash_create_with_parent_and_cascade(kanban_home):
# Parent then child via --parent
out1 = kc.run_slash("create 'parent' --assignee alice")