From 0c70e715892ccc2102ab0ba9e7ef115fbb986edd Mon Sep 17 00:00:00 2001 From: hy Date: Wed, 22 Apr 2026 21:54:29 +0800 Subject: [PATCH] fix: allow cached workspace clone from local repo --- monitor/service_release.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/monitor/service_release.py b/monitor/service_release.py index 91f4dd7..64208fe 100644 --- a/monitor/service_release.py +++ b/monitor/service_release.py @@ -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)