(self, target: str)
| 1647 | |
| 1648 | follow_cfg = _get_follow_cfg_for_repo_branch(repo, branch) |
| 1649 | if not isinstance(follow_cfg, dict): |
| 1650 | self._send_json(400, {"error": f"unknown repo/branch in config: {repo} {branch}"}) |
| 1651 | return |
| 1652 | |
| 1653 | run_cfg = follow_cfg.get("run") |
| 1654 | if not isinstance(run_cfg, dict): |
| 1655 | self._send_json(500, {"error": f"invalid follow.run config for: {repo} {branch}"}) |
| 1656 | return |
| 1657 | |
| 1658 | name_prefix = str(run_cfg.get("name_prefix") or "").strip() |
| 1659 | commands = run_cfg.get("commands") |
| 1660 | if not name_prefix: |
| 1661 | self._send_json(500, {"error": f"invalid follow.run.name_prefix for: {repo} {branch}"}) |
| 1662 | return |
| 1663 | if not isinstance(commands, list) or not commands: |
| 1664 | self._send_json(500, {"error": f"invalid follow.run.commands for: {repo} {branch}"}) |
| 1665 | return |
| 1666 | |
| 1667 | clone_path = _ensure_local_clone(repo, repos_dir) |
| 1668 | try: |
| 1669 | _run(["git", "fetch", "--all"], cwd=clone_path) |
| 1670 | except Exception as e: |
| 1671 | self._send_json(500, {"error": f"fetch failed: {e}"}) |
| 1672 | return |
| 1673 | |
| 1674 | run_dir = _run_dir_for(runs_dir, repo, branch, commit) |
| 1675 | short = commit[:7] |
| 1676 | run_id = f"rerun__{_safe_name(repo)}__{branch}__{datetime.now().strftime('%Y%m%d_%H%M%S')}__{short}" |
| 1677 | meta_dir = (run_meta_dir / run_id).resolve() |
| 1678 | meta_dir.mkdir(parents=True, exist_ok=True) |
| 1679 | |
| 1680 | progress_file = meta_dir / "progress.jsonl" |
| 1681 | result_file = meta_dir / "result.yaml" |
| 1682 | log_file = meta_dir / "run.log" |
| 1683 | |
| 1684 | _record_run_index( |
| 1685 | run_index_file, |
| 1686 | run_id, |
| 1687 | { |
| 1688 | "repo": repo, |
| 1689 | "branch": branch, |
| 1690 | "commit": commit, |
| 1691 | "name_prefix": name_prefix, |
| 1692 | "status": "running", |
| 1693 | "started_ts": datetime.now().isoformat(), |
| 1694 | "log_file": str(log_file), |
| 1695 | "progress_file": str(progress_file), |
| 1696 | "result_file": str(result_file), |
| 1697 | "run_dir": str(run_dir), |
| 1698 | "meta_dir": str(meta_dir), |
| 1699 | }, |
| 1700 | ) |
| 1701 | |
| 1702 | try: |
| 1703 | run_dir.parent.mkdir(parents=True, exist_ok=True) |
| 1704 | _clone_repo_at_commit(clone_path, run_dir, commit) |
| 1705 | |
| 1706 | rc, failed_step = _run_commands( |
no test coverage detected