pr_land.py python
50 lines 1.8 KB
Raw
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago
1 """``ok pr-land`` — authorized wait-for-green PR merge (Tier-3 delegated)."""
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.pr_land import run_pr_land
13
14
15 def run_pr_land_command(args: Namespace, ctx: CliContext) -> int:
16 """Execute ``ok pr-land``."""
17 repo_root = resolve_repo_root(cwd=ctx.cwd, repo_arg=args.repo, command="pr-land")
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 # Validate install; pr-land does not need close_ritual.enabled. The loaded
25 # config also carries close_ritual.post_land_sync + vcs.git for §PLS sync.
26 config = load_config(config_path)
27 except ConfigError as exc:
28 ctx.output.error(format_config_error(exc, repo_root))
29 return 2
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_pr_land(
36 str(args.pr),
37 authorization=str(args.authorized or ""),
38 merge_method=str(args.method),
39 poll_seconds=float(args.poll_seconds),
40 timeout_seconds=float(args.timeout_seconds),
41 allow_empty_checks=bool(args.allow_empty_checks),
42 dry_run=bool(args.dry_run),
43 emit=emit,
44 repo_root=repo_root,
45 config=config,
46 )
47
48 if ctx.output.json_mode:
49 ctx.output.emit_json(result.to_dict())
50 return result.exit_code
File History 1 commit
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago