Add make push / scripts/push.sh
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -3,9 +3,10 @@ export
|
|||||||
|
|
||||||
COMPOSE = docker compose
|
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:
|
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 fetch init/update the submodules (scripts/fetch.sh)"
|
||||||
@echo "make build generate the site into ./site-build"
|
@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)"
|
@echo "make up | down start/stop the local web server (http://127.0.0.1:8080)"
|
||||||
@@ -18,6 +19,9 @@ help:
|
|||||||
fetch:
|
fetch:
|
||||||
./scripts/fetch.sh
|
./scripts/fetch.sh
|
||||||
|
|
||||||
|
push:
|
||||||
|
./scripts/push.sh $(if $(DRY),--dry-run)
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(COMPOSE) --profile build run --rm build
|
$(COMPOSE) --profile build run --rm build
|
||||||
|
|
||||||
|
|||||||
@@ -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`.
|
`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
|
```console
|
||||||
$ git -C 50ohm-contents-dl commit -am "..." # work happens in the submodule
|
$ git -C 50ohm-contents-dl commit -am "..." # work happens in the submodule
|
||||||
|
|||||||
Executable
+29
@@ -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
|
||||||
Reference in New Issue
Block a user