From 5889cba730549c393c5cda2eaaceb85b0614fc3b Mon Sep 17 00:00:00 2001 From: Jakub Kocka Date: Mon, 17 Aug 2026 11:46:14 +0200 Subject: [PATCH] ci(tools): Fix worktree submodule copy of gitlink files --- tools/test_build_system/conftest.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/test_build_system/conftest.py b/tools/test_build_system/conftest.py index cbd67caf7f0..0fb2ec88673 100644 --- a/tools/test_build_system/conftest.py +++ b/tools/test_build_system/conftest.py @@ -70,10 +70,11 @@ def _create_idf_copy_via_worktree(path_from: Path, path_to: Path) -> str: # Only copy if source submodule exists and has content if src_submodule.exists() and any(src_submodule.iterdir()): logging.debug(f'copying submodule {submodule_rel_path}') - # Remove the empty directory created by worktree - if dst_submodule.exists(): - shutil.rmtree(dst_submodule, ignore_errors=True) - # Copy the submodule content + # Worktree submodule paths may be gitlink files; rmtree() does not remove those. + if dst_submodule.is_file() or dst_submodule.is_symlink(): + dst_submodule.unlink() + elif dst_submodule.exists(): + shutil.rmtree(dst_submodule) shutil.copytree(src_submodule, dst_submodule, symlinks=True, ignore=shutil.ignore_patterns('.git')) # Match old shutil-based idf_copy: no top-level .git (see docstring above).