From df72f6f16a7a5141ff4df1bab7e1de34207a4163 Mon Sep 17 00:00:00 2001 From: godosa Date: Wed, 7 Oct 2026 09:17:34 +0200 Subject: split projects 2/6: wf start makes code worktrees (.wf-home), wf next advice Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01JEAjUkQRrCYX5MZhWxdtj2 --- wf.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'wf.py') diff --git a/wf.py b/wf.py index 3a6babf..444cd37 100755 --- a/wf.py +++ b/wf.py @@ -392,6 +392,11 @@ def multi_lines(p: Project, args, lane: str, extra: int) -> list[str]: if wt: return [head + f"you are in worktree {p.cfg.rel(wt[0])} (branch {config.git_branch(wt[1])}); " "wf writes the main tree's TASKS.md"] + if code := config.code_main(p.cfg): + master = config.git_branch(code / ".git") or "master" + cmd = f"wf start --worktree {code / '.worktrees' / lane} --branch {lane}/" + return [head + f"work in your lane's code worktree, never on {master}:", + f" {cmd} (run in {p.cfg.root}; wf there writes this TASKS.md)"] folder, master = p.cfg.root / ".worktrees" / lane, config.git_branch(main_top / ".git") or "master" cmd = (f"cd {p.cfg.rel(folder)} && git switch -c {lane}/ {master}" if folder.is_dir() else f"git worktree add {p.cfg.rel(folder)} -b {lane}/ {master}") @@ -1424,7 +1429,8 @@ def cmd_start(args) -> int: p = load_project(args) id = p.resolve(args.id) main = Path(git_run(start, "rev-parse", "--show-toplevel").stdout.strip() or p.cfg.root) - master = config.git_branch(main / ".git") or "master" + repo = config.code_main(p.cfg) or main # split project: worktree + branch in the code repo + master = config.git_branch(repo / ".git") or "master" wt = (Path.cwd() / args.worktree).resolve() shown = p.cfg.rel(wt) b = args.branch @@ -1435,14 +1441,14 @@ def cmd_start(args) -> int: raise Failure(f"git {a[0]} failed: {(r.stderr.strip() or r.stdout.strip() or 'git error').splitlines()[-1]}") return r.stdout - has_branch = not git_run(main, "rev-parse", "--verify", "-q", f"refs/heads/{b}").returncode + has_branch = not git_run(repo, "rev-parse", "--verify", "-q", f"refs/heads/{b}").returncode extra = [] if not wt.exists(): if has_branch: - git_ok(main, "worktree", "add", "-q", str(wt), b) + git_ok(repo, "worktree", "add", "-q", str(wt), b) how = f"new, existing branch {b}: earlier WIP, read the notes" else: - git_ok(main, "worktree", "add", "-q", str(wt), "-b", b, master) + git_ok(repo, "worktree", "add", "-q", str(wt), "-b", b, master) how = f"new, branch {b} from {master}" else: dirty = git_run(wt, "status", "--porcelain").stdout.rstrip("\n") @@ -1467,6 +1473,8 @@ def cmd_start(args) -> int: extra = [f"recovery: uncommitted:\n{dirty}" if dirty else "recovery: uncommitted: none", f"recovery: commits {master}..HEAD:" + (f"\n{log}" if log else " none")] print(f"worktree: {shown} ({how})", *extra, sep="\n", flush=True) + if repo != main: + (wt / config.WF_HOME).write_text(f"{p.cfg.root}\n") try: here = wt / p.cfg.root.relative_to(main) except ValueError: -- cgit