Skip to content

Commit b0541c1

Browse files
andrewjongclaude
andcommitted
P2(rfc-379): sync self-heals stale partial module checkouts
A managed modules/<name> dir without .git (interrupted clone or partial remove) made vcs import fail with 'destination path already exists'; sync now clears such dirs before importing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent e58caad commit b0541c1

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎.airstack/modules/module.sh‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,24 @@ function cmd_module_sync {
285285
git_count="$(_module_git_count)"
286286
if [ "$git_count" -gt 0 ]; then
287287
_module_ensure_vcs || return 1
288+
# Self-heal: a managed checkout dir without .git (interrupted clone /
289+
# partial remove) makes `vcs import` fail with "destination path
290+
# already exists" — clear it so the import can reclone.
291+
local _mod_name _mod_dir
292+
while IFS= read -r _mod_name; do
293+
_mod_dir="$MODULE_CHECKOUT_DIR/$_mod_name"
294+
if [ -d "$_mod_dir" ] && [ ! -e "$_mod_dir/.git" ]; then
295+
log_warn "modules/${_mod_name} exists without .git (stale partial checkout) — clearing for reclone"
296+
rm -rf "$_mod_dir"
297+
fi
298+
done < <(MODULE_REPOS_FILE="$MODULE_REPOS_FILE" python3 - <<'PY'
299+
import os, yaml
300+
with open(os.environ["MODULE_REPOS_FILE"], encoding="utf-8") as f:
301+
data = yaml.safe_load(f) or {}
302+
for name in (data.get("repositories") or {}):
303+
print(name)
304+
PY
305+
)
288306
log_info "Importing ${git_count} pinned module repo(s) into modules/ (vcs import --recursive)..."
289307
if ! vcs import "$MODULE_CHECKOUT_DIR" --input "$MODULE_REPOS_FILE" --recursive; then
290308
log_error "vcs import failed — check the URLs/pins in modules.repos."

0 commit comments

Comments
 (0)