land_check.py
python
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
10 hours ago
| 1 | """``ok land-check`` — close-ritual verify_landed / prepare_pr (never merges).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from argparse import Namespace |
| 6 | |
| 7 | from adapters.config import load_config |
| 8 | from adapters.errors import ConfigError |
| 9 | from cli.context import CliContext |
| 10 | from cli.paths import is_within_repo, resolve_config_path, resolve_repo_root |
| 11 | from cli.sanitize import format_config_error |
| 12 | from tools.close_ritual.land_check import run_land_check |
| 13 | |
| 14 | |
| 15 | def run_land_check_command(args: Namespace, ctx: CliContext) -> int: |
| 16 | """Execute ``ok land-check``.""" |
| 17 | repo_root = resolve_repo_root(cwd=ctx.cwd, repo_arg=args.repo, command="land-check") |
| 18 | config_path = resolve_config_path(repo_root, args.config) |
| 19 | if not is_within_repo(repo_root, config_path): |
| 20 | ctx.output.error("refused: config path outside repo root") |
| 21 | return 4 |
| 22 | |
| 23 | try: |
| 24 | config = load_config(config_path) |
| 25 | except ConfigError as exc: |
| 26 | ctx.output.error(format_config_error(exc, repo_root)) |
| 27 | return 2 |
| 28 | |
| 29 | mode = getattr(args, "mode", None) |
| 30 | |
| 31 | def emit(line: str) -> None: |
| 32 | if not ctx.output.quiet and not ctx.output.json_mode: |
| 33 | ctx.output.emit(line) |
| 34 | |
| 35 | result = run_land_check(config, repo_root, mode=mode, emit=emit) |
| 36 | |
| 37 | if ctx.output.json_mode: |
| 38 | ctx.output.emit_json( |
| 39 | { |
| 40 | "exit_code": result.exit_code, |
| 41 | "landed": result.landed, |
| 42 | "mode": result.mode, |
| 43 | "ref": result.ref, |
| 44 | "paths": list(result.paths), |
| 45 | "dirty_paths": list(result.dirty_paths), |
| 46 | "auto_merge": False, |
| 47 | "messages": list(result.messages), |
| 48 | } |
| 49 | ) |
| 50 | return result.exit_code |
File History
1 commit
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
10 hours ago