#!/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) 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