Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
90 lines
2.5 KiB
Bash
90 lines
2.5 KiB
Bash
#!/usr/bin/env bash
|
|
# Check sync status of all nine HYBX sidecars vs Gitea. Run from proxmox repo root.
|
|
# Usage: bash scripts/check-hybx-sidecars-sync.sh
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
[ -f "$PROJECT_ROOT/.env" ] && set +u && source "$PROJECT_ROOT/.env" 2>/dev/null || true && set -u
|
|
|
|
GITEA_ORG="${GITEA_ORG:-HYBX}"
|
|
GITEA_URL="${GITEA_URL:-https://gitea.d-bis.org}"
|
|
BASE="${HYBX_SIDECARS_BASE:-/home/intlc/projects/HYBX_Sidecars}"
|
|
export GITEA_TOKEN
|
|
CRED_HELPER="!f() { echo \"username=git\"; echo \"password=\$GITEA_TOKEN\"; }; f"
|
|
|
|
REPOS=(
|
|
mifos-fineract-sidecar
|
|
mt103-hardcopy-sidecar
|
|
off-ledger-2-on-ledger-sidecar
|
|
securitization-engine-sidecar
|
|
card-networks-sidecar
|
|
securities-sidecar
|
|
flash-loan-xau-sidecar
|
|
server-funds-sidecar
|
|
docs-for-sidecars
|
|
)
|
|
|
|
echo "Checking sync: $BASE vs gitea $GITEA_URL/$GITEA_ORG"
|
|
echo ""
|
|
|
|
synced=0
|
|
behind=0
|
|
ahead=0
|
|
missing=0
|
|
other=0
|
|
|
|
for name in "${REPOS[@]}"; do
|
|
dir="$BASE/$name"
|
|
if [ ! -d "$dir" ]; then
|
|
echo " $name: MISSING (dir not found)"
|
|
((missing++)) || true
|
|
continue
|
|
fi
|
|
if [ ! -d "$dir/.git" ]; then
|
|
echo " $name: NOT A REPO"
|
|
((other++)) || true
|
|
continue
|
|
fi
|
|
|
|
branch=main
|
|
# Fetch so we have up-to-date gitea/main
|
|
if git -C "$dir" remote get-url gitea &>/dev/null; then
|
|
git -C "$dir" -c "credential.helper=$CRED_HELPER" fetch gitea "$branch" 2>/dev/null || true
|
|
fi
|
|
|
|
local_sha=$(git -C "$dir" rev-parse "$branch" 2>/dev/null || echo "")
|
|
remote_sha=$(git -C "$dir" rev-parse "gitea/$branch" 2>/dev/null || echo "")
|
|
|
|
if [ -z "$remote_sha" ]; then
|
|
echo " $name: NO REMOTE (gitea/$branch not found)"
|
|
((other++)) || true
|
|
continue
|
|
fi
|
|
|
|
if [ "$local_sha" = "$remote_sha" ]; then
|
|
echo " $name: SYNCED ($local_sha)"
|
|
((synced++)) || true
|
|
continue
|
|
fi
|
|
|
|
if git -C "$dir" merge-base --is-ancestor "$remote_sha" "$local_sha" 2>/dev/null; then
|
|
echo " $name: AHEAD (local has new commits; push to sync)"
|
|
((ahead++)) || true
|
|
elif git -C "$dir" merge-base --is-ancestor "$local_sha" "$remote_sha" 2>/dev/null; then
|
|
echo " $name: BEHIND (pull to sync)"
|
|
((behind++)) || true
|
|
else
|
|
echo " $name: DIVERGED (local and remote have different commits)"
|
|
((other++)) || true
|
|
fi
|
|
done
|
|
|
|
echo ""
|
|
echo "Summary: $synced synced, $ahead ahead, $behind behind, $missing missing, $other other"
|
|
if [ "$behind" -gt 0 ] || [ "$ahead" -gt 0 ]; then
|
|
echo "Run: bash scripts/push-hybx-sidecars-to-gitea.sh --sync to sync all"
|
|
exit 1
|
|
fi
|
|
exit 0
|