Files
Odoo-Modules/sync-push-all.sh
gsinghpal 4830613701 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>
2026-06-09 21:34:32 -04:00

37 lines
1.2 KiB
Bash
Executable File

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