Files
prompts/script/update-policy
T
clawbot 454f3410a1
check / check (push) Successful in 31s
Add script/install; script/update-policy runs it and commits (closes #165)
script/install fetches the policy files from prompts over HTTP and
writes them into a repo, installing itself and script/update-policy
there. script/update-policy fetches the current script/install, runs
it on its own repo and commits without pushing. The file list and the
rules for keeping a repo's own entries move to script/install.

Model: opus-5-5
2026-11-09 18:32:46 +00:00

44 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
# script/update-policy: bring this repo up to standards. It fetches the
# current script/install from the prompts repo over HTTP, runs it on this
# repo and commits the files it wrote. It does not push. Identical in all
# repos. Our own extension to scripts-to-rule-them-all.
set -eu
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
INSTALL_URL="https://git.eeqj.de/sneak/prompts/raw/branch/main/script/install"
die() {
echo "update-policy: $*" >&2
exit 1
}
main() {
[ "$#" -eq 0 ] || die "usage: script/update-policy"
cd "$ROOT"
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
curl --fail --silent --show-error --max-time 60 \
--output "$tmp/install" "$INSTALL_URL" ||
die "cannot fetch $INSTALL_URL"
sh "$tmp/install" "$ROOT" > "$tmp/written"
commit="$(head -n 1 "$tmp/written")"
paths="$(tail -n +2 "$tmp/written")"
for path in $paths; do
git add -- "$path"
done
if git diff --cached --quiet -- $paths; then
echo "update-policy: already at prompts $commit, nothing to commit"
else
git commit -m "Update policy files from prompts $commit" -- $paths
fi
}
main "$@"