Answer stability round 2: 1 🔴, 1 🟡 (0 misread); remove a failed clone's leftovers and make git prompts fail
CI / tests (pull_request) Failing after 3m57s
CI / tests (pull_request) Failing after 3m57s
This commit is contained in:
@@ -4,6 +4,7 @@ A missing checkout is cloned from the host and owner of the epic's other repos (
|
||||
import dataclasses
|
||||
import pathlib
|
||||
import re
|
||||
import shutil
|
||||
|
||||
from do_epic.config import DoEpicConfig
|
||||
from failure import Failure
|
||||
@@ -15,8 +16,10 @@ from project_config.settings import by_name, CONFIG, ProjectConfig, PROJECTS
|
||||
REPO_NAME = r"\w[\w.-]*"
|
||||
# The addresses a clone may use: https, ssh, or scp-style `user@host:path`. Not ext:: or file:, which run a program or read this machine's files, and an origin can spell either.
|
||||
CLONE_ADDRESS = rf"https://[\w.-]+(:\d+)?/\S+|ssh://[\w.@-]+(:\d+)?/\S+|\w[\w.-]*@[\w.-]+:[\w./~-]+"
|
||||
# A clone that waits longer is stopped, as on a prompt for a password or a host key.
|
||||
# A clone that waits longer is stopped.
|
||||
CLONE_SECONDS = 600
|
||||
# git's options that make a password or a host key fail at once instead of prompting: an unattended run never waits on a prompt (docs/decisions.md → principle 6).
|
||||
NO_PROMPTS = ("-c", "core.askPass=true", "-c", "core.sshCommand=ssh -o BatchMode=yes")
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -59,8 +62,10 @@ def ensure(name: str, checkout: pathlib.Path, others: list[pathlib.Path], git: G
|
||||
url = clone_url(name, others, git)
|
||||
if isinstance(url, Failure):
|
||||
return url
|
||||
cloned = git("clone", "--", url, str(checkout), timeout=CLONE_SECONDS)
|
||||
cloned = git(*NO_PROMPTS, "clone", "--", url, str(checkout), timeout=CLONE_SECONDS)
|
||||
if isinstance(cloned, Failure):
|
||||
# What the clone began, and nothing else: checkout was absent or empty. A kept half-clone would pass for the repo on the next run.
|
||||
shutil.rmtree(checkout, ignore_errors=True)
|
||||
return Unsure(f"cannot clone {url} to {checkout}: {cloned.reason}. Where does {name} live?")
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user