4NK_env/scripts/push-ext-commit.sh
LeCoffre Deployment 74ca619b6a auto_clea
2025-09-25 12:55:10 +00:00

57 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
echo "[push-ext-commit] Ensure all submodules on ext, commit if needed, push ext"
# Work from repo root
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"
# Update submodules metadata (non-recursive update of refs; content is already cloned)
git submodule init >/dev/null 2>&1 || true
git submodule foreach --recursive '
set -e
echo "[submodule] Enter: $name ($path)"
git fetch origin ext || true
if ! git rev-parse --verify ext >/dev/null 2>&1; then
if git show-ref --verify --quiet refs/remotes/origin/ext; then
git switch -C ext origin/ext
else
git switch -C ext
fi
else
git switch ext
fi
git pull --ff-only || true
git add -A
if ! git diff --cached --quiet; then
git commit -m "auto_clea"
git push -u origin ext || true
else
echo "[submodule] No changes to commit"
fi
'
echo "[root] Process root repository"
git fetch origin ext || true
if ! git rev-parse --verify ext >/dev/null 2>&1; then
if git show-ref --verify --quiet refs/remotes/origin/ext; then
git switch -C ext origin/ext
else
git switch -C ext
fi
else
git switch ext
fi
git pull --ff-only || true
git add -A
if ! git diff --cached --quiet; then
git commit -m "auto_clea"
git push -u origin ext
else
echo "[root] No changes to commit"
fi
echo "[push-ext-commit] Done."