Files
prompts/script/update-policy
T
clawbot ed60414378
check / check (push) Canceled after 0s
Rename script/fetch-policy to script/commit-current-upstream-policy-docs
sneak, on the PR: the script does more than fetch, and short names are
not wanted. The make target, the test names, the variables and the
messages take the new name. Behaviour is unchanged.

Model: opus-5-5
2026-11-11 00:00:28 +00:00

46 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
# script/update-policy: bring this repo up to standards. It fetches the
# current script/commit-current-upstream-policy-docs 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)"
COMMIT_CURRENT_UPSTREAM_POLICY_DOCS_URL="https://git.eeqj.de/sneak/prompts/raw/branch/main/script/commit-current-upstream-policy-docs"
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/commit-current-upstream-policy-docs" \
"$COMMIT_CURRENT_UPSTREAM_POLICY_DOCS_URL" ||
die "cannot fetch $COMMIT_CURRENT_UPSTREAM_POLICY_DOCS_URL"
sh "$tmp/commit-current-upstream-policy-docs" "$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 "$@"