Files
Odoo-Modules/sync-pull-all.sh
gsinghpal eddec0bb6e sync scripts: self-heal gitea remote if a fresh clone dropped it
Re-clones from GitHub leave repos with only origin; pull/push now re-add the
gitea mirror remote automatically so the mirror cannot silently drift.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 21:41:12 -04:00

49 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Pull the latest for the parent repo + every module repo.
# Fast-forward only: it NEVER overwrites or deletes your local work. If a repo has
# diverged or has conflicting local changes, it is skipped and reported so you can
# handle it by hand. Clones any module folder that is missing.
# Run this before you start working on a machine.
#
# bash sync-pull-all.sh
set -uo pipefail
cd "$(dirname "$0")" || exit 1
GH="https://github.com/gsinghpal"
GITEA="https://git.nexasystems.ca/admin"
pull_one() {
local d="$1"
local br; br=$(git -C "$d" symbolic-ref --short HEAD 2>/dev/null || echo main)
# self-heal: re-add the gitea mirror remote if a fresh clone dropped it
if [ "$d" != "." ] && ! git -C "$d" remote get-url gitea >/dev/null 2>&1; then
git -C "$d" remote add gitea "https://git.nexasystems.ca/admin/$d.git" 2>/dev/null || true
fi
if git -C "$d" pull --ff-only -q origin "$br" 2>/dev/null; then
echo "updated: $d"
else
if [ -n "$(git -C "$d" status --porcelain --untracked-files=no)" ]; then
echo "SKIP (uncommitted changes block ff): $d -> commit, then re-run"
else
echo "SKIP (diverged, needs manual merge): $d"
fi
fi
}
echo "== parent =="
pull_one .
[ -f repos.txt ] || { echo "repos.txt not found"; exit 1; }
echo "== modules =="
while IFS= read -r f; do
case "$f" in ''|\#*) continue ;; esac
if [ ! -d "$f/.git" ]; then
if git clone -q "$GH/$f.git" "$f"; then
git -C "$f" remote add gitea "$GITEA/$f.git" 2>/dev/null || true
echo "cloned (was missing): $f"
else
echo "FAILED clone: $f"
fi
continue
fi
pull_one "$f"
done < repos.txt