#!/usr/bin/env bash # Push all repos to origin: the three submodules (branch sv) first, then this repo (branch main). # The parent records the submodules' commit hashes, so they must exist on the remote before it. # # scripts/push.sh push everything # scripts/push.sh --dry-run show what would be pushed (still contacts the remotes) set -euo pipefail cd "$(dirname "$0")/.." DRY=() [[ "${1:-}" == "--dry-run" ]] && DRY=(--dry-run) # Refuse to push with uncommitted work: the parent would pin a commit that lacks it. dirty=0 for repo in 50ohm 50ohm-contents-dl 50ohm-ansible .; do if [[ -n "$(git -C "$repo" status --porcelain --ignore-submodules=none)" ]]; then echo "Uncommitted changes in ${repo/#./deploy (parent)}:" >&2 git -C "$repo" status --short --ignore-submodules=none | head -5 >&2 dirty=1 fi done (( dirty == 0 )) || { echo "Commit first, then run again." >&2; exit 1; } for repo in 50ohm 50ohm-contents-dl 50ohm-ansible; do echo "== $repo (sv)" git -C "$repo" push "${DRY[@]}" -u origin sv done echo "== 50ohm-deploy (main)" git push "${DRY[@]}" -u origin main