fix: allow cached workspace clone from local repo

This commit is contained in:
hy 2026-04-22 21:54:29 +08:00
parent 67f58e4c57
commit 0c70e71589

View File

@ -396,6 +396,20 @@ def prepare_persistent_build_workspace(
workspace_root = persistent_build_workspace_path(repo_root, git_ref)
workspace_root.parent.mkdir(parents=True, exist_ok=True)
# 源仓有时由别的用户维护git clone 本地路径前先显式加入 safe.directory。
local_command_output(
["git", "config", "--global", "--add", "safe.directory", str(repo_root)],
cwd=workspace_root.parent,
label=f"{label} allow source repo",
timeout_seconds=120,
)
local_command_output(
["git", "config", "--global", "--add", "safe.directory", str(repo_root / '.git')],
cwd=workspace_root.parent,
label=f"{label} allow source repo dotgit",
timeout_seconds=120,
)
if not (workspace_root / ".git").exists():
if workspace_root.exists():
shutil.rmtree(workspace_root, ignore_errors=True)