From 62c958022a7bdbbaa1e5a6942eb3d0a977b7ce50 Mon Sep 17 00:00:00 2001 From: Carl Vargklint Date: Sat, 10 Oct 2026 15:50:31 +0200 Subject: [PATCH] Add make push / scripts/push.sh Co-Authored-By: Claude Sonnet 5.5 --- Makefile | 6 +++++- README.md | 4 +++- scripts/push.sh | 29 +++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100755 scripts/push.sh diff --git a/Makefile b/Makefile index 7918d7a..e6520e6 100644 --- a/Makefile +++ b/Makefile @@ -3,9 +3,10 @@ export COMPOSE = docker compose -.PHONY: help fetch build up down logs rebuild drawings drawings-all drawings-one shell-latex remotes +.PHONY: help fetch push build up down logs rebuild drawings drawings-all drawings-one shell-latex remotes help: + @echo "make push push the three repos (sv), then this one (main); DRY=1 for a dry run" @echo "make fetch init/update the submodules (scripts/fetch.sh)" @echo "make build generate the site into ./site-build" @echo "make up | down start/stop the local web server (http://127.0.0.1:8080)" @@ -18,6 +19,9 @@ help: fetch: ./scripts/fetch.sh +push: + ./scripts/push.sh $(if $(DRY),--dry-run) + build: $(COMPOSE) --profile build run --rm build diff --git a/README.md b/README.md index 0fffa1b..9c673b0 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,9 @@ $ make build && make up `scripts/fetch.sh --pinned` checks out exactly the commits recorded in this repo instead of the tip of `sv`. -**Pushing.** A submodule records a commit hash, so commit and push inside the submodule first, then record the new hash in the parent. `push.recurseSubmodules=on-demand` is set, so from the parent: +**Pushing everything:** `make push` (or `scripts/push.sh`) pushes the three submodules on `sv` first and then this repo on `main`; it refuses to run while anything is uncommitted. `make push DRY=1` is a dry run. + +**By hand.** A submodule records a commit hash, so commit and push inside the submodule first, then record the new hash in the parent. `push.recurseSubmodules=on-demand` is set, so from the parent: ```console $ git -C 50ohm-contents-dl commit -am "..." # work happens in the submodule diff --git a/scripts/push.sh b/scripts/push.sh new file mode 100755 index 0000000..832ae7e --- /dev/null +++ b/scripts/push.sh @@ -0,0 +1,29 @@ +#!/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