refactor: one autorun worktree path and checkout

This commit is contained in:
Abdessamad Derraz committed 2026-11-21 19:50:46 +01:00
1 parent 6c92b0172e
commit eec4ff9972
6 files changed
+29 -17

No files matched your search

+12
View File
@@ -4,6 +4,7 @@ from __future__ import annotations
import re
import subprocess
from pathlib import Path
class GitRefused(RuntimeError):
@@ -37,6 +38,17 @@ def required_git_lines(*args: str) -> list[str]:
return _lines(result.stdout)
def main_checkout(cwd: Path) -> Path:
"""The main checkout of the clone holding cwd, also from a linked worktree,
GitRefused when cwd is in no clone."""
args = ("rev-parse", "--path-format=absolute", "--git-common-dir")
result = _run(("-C", str(cwd), *args))
if result.returncode:
detail = result.stderr.strip() or f"exit {result.returncode}"
raise GitRefused(f"git {' '.join(args)}: {detail}")
return Path(result.stdout.strip()).parent
# Where a clone with no remote naming the project keeps its main line, each
# remote's names in the order tried.
FALLBACK_REMOTES = ("upstream", "origin")
+4
View File
@@ -19,6 +19,10 @@ BIOS_DIR = "bios"
DATA_DIRS_FILE = f"{PLATFORMS_DIR}/_data_dirs.yml"
# Where generate_truth writes its models and diff_truth and export_native read them.
TRUTH_DIR = "dist/truth"
# The unattended runner's home, and the worktree it commits from, which disk
# cleanup must never take for an idle session worktree.
AUTORUN_DIR = ".cache/autorun"
AUTORUN_WORKTREE = f"{AUTORUN_DIR}/worktree"
def sanitize_pack_path(raw: str) -> str: