From d578c1924530005a8f422c4895af076bf09afcf1 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 22 Sep 2026 22:07:30 +0200 Subject: [PATCH] Add a script for re-recording every demo a page embeds Changing demo/settings.tape, or anything about how lazygit looks, dates every recording at once, and re-recording them one at a time means running the recorder fifteen times and pasting fifteen new URLs. Attachment URLs say nothing about where they came from, so there is also nothing to tell you which demo a video in the README is of. Name the demo in a comment above each video. GitHub drops the comment when it renders the page, so it costs the reader nothing, and it gives us a way back from a page to the demo that produced it. Then walk those comments, re-record each demo and rewrite the URL below it. Co-Authored-By: Claude Opus 5 (1M context) --- Makefile | 4 + demo/rerecord_demos.sh | 113 +++++++++++++++++++++++++++++ docs-master/dev/Demo_Recordings.md | 23 ++++++ justfile | 4 + scripts/rerecord_demos.sh | 3 + 5 files changed, 147 insertions(+) create mode 100755 demo/rerecord_demos.sh create mode 100755 scripts/rerecord_demos.sh diff --git a/Makefile b/Makefile index 3e56a2821..c1af01d7a 100644 --- a/Makefile +++ b/Makefile @@ -68,6 +68,10 @@ bump-lazycore: record-demo: demo/record_demo.sh $(filter-out $@,$(MAKECMDGOALS)) +.PHONY: rerecord-demos +rerecord-demos: + demo/rerecord_demos.sh $(filter-out $@,$(MAKECMDGOALS)) + .PHONY: vendor vendor: go mod tidy && go mod vendor diff --git a/demo/rerecord_demos.sh b/demo/rerecord_demos.sh new file mode 100755 index 000000000..db5c7140c --- /dev/null +++ b/demo/rerecord_demos.sh @@ -0,0 +1,113 @@ +#!/bin/sh + +set -e + +# Re-records the demos that a page embeds and points the page at the new +# videos. Use it when a change to demo/settings.tape, or to lazygit's +# appearance, leaves the existing recordings looking out of date. +# +# A page names the demo behind each video in a comment above it: +# +# +# +# +# GitHub drops that comment when it renders the page, so it costs the reader +# nothing. This script re-records the demo the comment names and rewrites the +# URL on the line below it. + +usage() { + echo "Usage: $0 [--no-upload] [page ...]" + echo "e.g. $0 README.md" + echo + echo "Re-records every demo the given pages embed. With no page given," + echo "that means README.md." + echo + echo "--no-upload leaves the videos in demo/output and the pages untouched," + echo "which is what you want for reviewing a change to demo/settings.tape." + exit 1 +} + +NO_UPLOAD= + +if [ "$1" = "--no-upload" ] +then + NO_UPLOAD=--no-upload + shift +fi + +if [ "$1" = "-h" ] || [ "$1" = "--help" ] +then + usage +fi + +if [ ! -x demo/record_demo.sh ] +then + echo "Run this from the root of the repository." + exit 1 +fi + +if [ "$#" -eq 0 ] +then + set -- README.md +fi + +for PAGE in "$@" +do + if [ ! -f "$PAGE" ] + then + echo "$PAGE does not exist" + exit 1 + fi + + NAMES=$(sed -n 's/^$/\1/p' "$PAGE") + + if [ -z "$NAMES" ] + then + echo "$PAGE embeds no demos. Each video needs a " + echo "comment on the line above it to say which demo it came from." + exit 1 + fi + + for NAME in $NAMES + do + TEST="pkg/integration/tests/demo/$NAME.go" + + if [ ! -f "$TEST" ] + then + echo "$PAGE asks for a demo called $NAME, but $TEST does not exist" + exit 1 + fi + + echo + echo "=== $NAME ===" + + if [ -n "$NO_UPLOAD" ] + then + demo/record_demo.sh --no-upload "$TEST" + continue + fi + + # Keep the recording chatter on screen, since a full run takes a while, + # and read the new URL back out of it afterwards. + LOG=$(mktemp) + demo/record_demo.sh "$TEST" | tee "$LOG" + URL=$(sed -n 's/.*