Add cross-machine sync tooling (clone/pull/push all module repos)
repos.txt + sync-*.sh let any machine (Mac or Windows/Git Bash) hydrate all 49 module repos and keep them in sync via GitHub+gitea. Pulls are fast-forward only (never clobber local work); pushes send commits only and flag uncommitted repos. See SYNC.md for the two-machine workflow. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
44
sync-pull-all.sh
Executable file
44
sync-pull-all.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user