From a5de9701cb73c2553fb23134287701f850210b1c Mon Sep 17 00:00:00 2001 From: Nicolas Cantu Date: Wed, 10 Sep 2025 13:40:33 +0200 Subject: [PATCH] ci: sanitize orphan submodule configs before sync/update to avoid missing .gitmodules entries --- .gitea/workflows/dev.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.gitea/workflows/dev.yml b/.gitea/workflows/dev.yml index 69e3d1f..ea4c1a3 100644 --- a/.gitea/workflows/dev.yml +++ b/.gitea/workflows/dev.yml @@ -31,6 +31,17 @@ jobs: password: ${{ secrets.TOKEN }} - name: Init submodules (ensure up-to-date) run: | + echo "Sanitize submodule config" + ALLOWED_PATHS=$(git config -f .gitmodules --get-regexp '^submodule\..*\.path$' | awk '{print $3}' || true) + for NAME in $(git config --local --name-only --get-regexp '^submodule\..*\.path$' | sed 's/\.path$//' || true); do + P=$(git config --local --get "$NAME.path" || true) + if ! printf "%s\n" "$ALLOWED_PATHS" | grep -qx "$P"; then + echo "[ci] deinit orphan submodule: $P ($NAME)" + git submodule deinit -f -- "$P" || true + git config --local --remove-section "$NAME" || true + rm -rf ".git/modules/$P" || true + fi + done git submodule sync --recursive git submodule update --init --recursive - name: Build and push images