#!/usr/bin/env bash # Push your committed work for the parent + every module repo to BOTH GitHub # (origin) and gitea. Only commits are pushed. Any repo that still has UNCOMMITTED # changes is flagged, so you can see exactly what has not been synced yet. # Run this after you finish working, once you have committed your changes. # # bash sync-push-all.sh set -uo pipefail cd "$(dirname "$0")" || exit 1 push_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 local flag="" [ -n "$(git -C "$d" status --porcelain --untracked-files=no)" ] && flag=" [HAS UNCOMMITTED CHANGES - not pushed]" local any=0 for r in origin gitea; do git -C "$d" remote get-url "$r" >/dev/null 2>&1 || continue any=1 if git -C "$d" push -q "$r" "$br" 2>/dev/null; then echo "pushed: $d -> $r$flag" else echo "push FAILED (or nothing to push): $d -> $r$flag" fi done [ "$any" = 0 ] && echo "no remotes: $d" } echo "== parent ==" push_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 push_one "$f"; else echo "skip (not cloned): $f"; fi done < repos.txt