From 413df931894dcc4529a73723f49790c9a958ed6b Mon Sep 17 00:00:00 2001 From: Mike-Swanson Date: Mon, 25 May 2026 09:12:08 -0700 Subject: [PATCH] fix(sync): init submodules on fresh clones; drop orphaned solverbot gitlink MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 1a used `git submodule foreach`, which only visits initialized submodules — a fresh machine silently skipped population while the script still reported success. It now explicitly inits + populates each submodule declared in .gitmodules (inheriting credentials from the parent origin URL so non-interactive init authenticates; .gitmodules stays credential-free), then advances each to its remote branch tip. Reporting reflects the real configured count. Also removes the orphaned `projects/solverbot` gitlink (mode 160000), committed without a .gitmodules entry, which made `git submodule status` throw `fatal: no submodule mapping`. solverbot's own Gitea repo is untouched. Co-Authored-By: Claude Opus 4.7 (1M context) --- .claude/scripts/sync.sh | 42 +++++++++++++++++++++++++++++++++++++++-- projects/solverbot | 1 - 2 files changed, 40 insertions(+), 3 deletions(-) delete mode 160000 projects/solverbot diff --git a/.claude/scripts/sync.sh b/.claude/scripts/sync.sh index ceb5b25..ff0e173 100755 --- a/.claude/scripts/sync.sh +++ b/.claude/scripts/sync.sh @@ -93,13 +93,51 @@ fi echo -e "${GREEN}[OK]${NC} Syncing as: $USER_DISPLAY (machine: $MACHINE)" # Phase 1a: Update submodules to latest remote +# `git submodule foreach` only visits *initialized* submodules, so a fresh clone +# would silently skip population and the old "[OK] updated" message lied. We now +# explicitly init+populate each submodule declared in .gitmodules, then advance +# it to its remote branch tip. Iterating .gitmodules (not the index) sidesteps +# any orphaned gitlink that lacks a .gitmodules mapping. Credentials are inherited +# from the parent origin URL so non-interactive init works without a credential +# helper; .gitmodules itself stays credential-free. echo "" echo "=== Phase 1a: Submodule update ===" -if [ -f ".gitmodules" ]; then +if [ -f ".gitmodules" ] && git config --file .gitmodules --get-regexp '^submodule\..*\.path$' >/dev/null 2>&1; then # Temporarily disable errexit — submodule ops emit non-fatal warnings that # would otherwise kill the script under set -e. set +e + + # If origin embeds credentials (https://user:pass@host/...), reuse its + # scheme+userinfo+host for submodule clones. + PARENT_URL="$(git config --get remote.origin.url)" + CRED_HOST="" + case "$PARENT_URL" in + https://*@*) CRED_HOST="$(printf '%s' "$PARENT_URL" | sed -E 's#^(https://[^/]+)/.*#\1#')" ;; + esac + + SUB_COUNT=0 + while read -r pkey ppath; do + [ -z "$ppath" ] && continue + name="$(printf '%s' "$pkey" | sed -E 's#^submodule\.(.*)\.path$#\1#')" + SUB_COUNT=$((SUB_COUNT + 1)) + # Register in .git/config (no-op if already initialized). + git submodule init -- "$ppath" >/dev/null 2>&1 + # Override the local clone URL with credentials when available. + if [ -n "$CRED_HOST" ]; then + gm_url="$(git config --file .gitmodules --get "submodule.${name}.url")" + case "$gm_url" in + https://*) + sub_path="$(printf '%s' "$gm_url" | sed -E 's#^https://[^/]+(/.*)#\1#')" + git config "submodule.${name}.url" "${CRED_HOST}${sub_path}" + ;; + esac + fi + # Populate if missing (fresh clone) at the pinned commit. + git submodule update --init -- "$ppath" >/dev/null 2>&1 + done < <(git config --file .gitmodules --get-regexp '^submodule\..*\.path$') + + # Advance each initialized submodule to its remote branch tip. git submodule foreach --quiet ' git fetch origin --quiet 2>/dev/null git checkout main --quiet 2>/dev/null || git checkout master --quiet 2>/dev/null @@ -107,7 +145,7 @@ if [ -f ".gitmodules" ]; then git merge --ff-only origin/master --quiet 2>/dev/null ' 2>/dev/null set -e - echo -e "${GREEN}[OK]${NC} Submodules updated to latest remote (on branch)." + echo -e "${GREEN}[OK]${NC} Submodules init+advanced (${SUB_COUNT} configured)." else echo -e "${GREEN}[OK]${NC} No submodules." fi diff --git a/projects/solverbot b/projects/solverbot deleted file mode 160000 index 60b2617..0000000 --- a/projects/solverbot +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 60b2617651d1f6a7786a673fca8a6ef8e41662c0