aboutsummaryrefslogtreecommitdiffziptar.gz
path: root/wf.py
diff options
context:
space:
mode:
authorgodosa <godosa@godosa.eu>2026-10-07 09:17:34 +0200
committergodosa <godosa@godosa.eu>2026-10-07 09:17:34 +0200
commitdf72f6f16a7a5141ff4df1bab7e1de34207a4163 (patch)
treed248d09369f3713c8f47bccb314c5a2eb82a7d40 /wf.py
parent0f6857c26e5b2777c6be927dbc75fdcdbfe0e750 (diff)
downloadworkflow-df72f6f16a7a5141ff4df1bab7e1de34207a4163.tar.gz
workflow-df72f6f16a7a5141ff4df1bab7e1de34207a4163.zip
split projects 2/6: wf start makes code worktrees (.wf-home), wf next advice
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JEAjUkQRrCYX5MZhWxdtj2
Diffstat (limited to 'wf.py')
-rwxr-xr-xwf.py16
1 files changed, 12 insertions, 4 deletions
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 <task> --worktree {code / '.worktrees' / lane} --branch {lane}/<task>"
+ 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}/<task> {master}" if folder.is_dir()
else f"git worktree add {p.cfg.rel(folder)} -b {lane}/<task> {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: