diff options
| author | godosa <godosa@godosa.eu> | 2026-10-07 09:40:59 +0200 |
|---|---|---|
| committer | godosa <godosa@godosa.eu> | 2026-10-07 09:40:59 +0200 |
| commit | 0e1e107192882809da7e660c09ba501c09331c38 (patch) | |
| tree | 32b2fd332464ca028c4dc5a8b03a216edeeb3229 /wflib | |
| parent | 811de09feb866c5b344034399154bde77acdd5ba (diff) | |
| download | workflow-0e1e107192882809da7e660c09ba501c09331c38.tar.gz workflow-0e1e107192882809da7e660c09ba501c09331c38.zip | |
split projects 6/6: wf check split rules; docs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JEAjUkQRrCYX5MZhWxdtj2
Diffstat (limited to 'wflib')
| -rw-r--r-- | wflib/check.py | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/wflib/check.py b/wflib/check.py index f86b2fe..c528c43 100644 --- a/wflib/check.py +++ b/wflib/check.py @@ -8,7 +8,7 @@ from dataclasses import dataclass from pathlib import Path from . import areas, refs, tasks -from .config import NAME, Config +from .config import NAME, WF_HOME, Config, git_top NUMBERED_RE = re.compile(r"^\d+\. ") NUMBER_REF_RE = re.compile(r"(?<![\w/&#])#\d+\b") @@ -301,7 +301,7 @@ def _git(root: Path, *args: str) -> str | None: return out.stdout.strip() if out.returncode == 0 else None -def merged_tool_worktrees(tool_root: Path) -> list[Problem]: +def merged_tool_worktrees(tool_root: Path, label: str = "tool") -> list[Problem]: """Worktrees of the wf tool repo whose branch is behind master (merged, leftover after release). A branch equal to master, or a worktree created < 2h ago, is not flagged.""" listing = _git(tool_root, "worktree", "list", "--porcelain") @@ -326,11 +326,27 @@ def merged_tool_worktrees(tool_root: Path) -> list[Problem]: except OSError: pass if _git(tool_root, "merge-base", "--is-ancestor", branch, "master") is not None: - out.append(Problem("wf-tool", None, "", f"tool worktree '{path}' (branch {branch}) is merged into " + out.append(Problem("wf-tool", None, "", f"{label} worktree '{path}' (branch {branch}) is merged into " f"master: git worktree remove it, git branch -d {branch}")) return out +def split_problems(cfg: Config) -> tuple[list[Problem], list[Problem]]: + """Split project rules (code_root = another repo): cloud refused, push expected, .wf-home ignored, merged code worktrees.""" + if not cfg.split: + return [], [] + code = git_top(cfg.code_root) + errors, warnings = [], [] + if cfg.cloud: + errors.append(Problem("workflow.toml", None, "", "cloud lane needs a single repo: split project (code_root is another repo)")) + if not cfg.push: + warnings.append(Problem("workflow.toml", None, "", "split project without push: public repo pushed unscanned or not at all")) + if _git(code, "check-ignore", "-q", WF_HOME) is None: + warnings.append(Problem(f"{code}/.gitignore", None, "", f"{WF_HOME} not git-ignored (wf start writes it into code worktrees)")) + warnings += merged_tool_worktrees(code, label="code") + return errors, warnings + + def _area_problems(cfg: Config) -> list[Problem]: file = cfg.areas_file if not file.is_file(): @@ -371,6 +387,9 @@ def check(cfg: Config, tasks_text: str | None = None, archive_text: str | None = if slow: warnings += _stale_awaiting(cfg, text) warnings += _area_problems(cfg) + e, w = split_problems(cfg) + errors += e + warnings += w order: dict[str, int] = {} for p in errors + warnings: order.setdefault(p.path, len(order)) |
