1 Commits
Author SHA1 Message Date
sneak 47b35661a2 Replace script/update-policy with a short wget-and-commit script (closes #165)
check / check (push) Successful in 13s
The script fetches a fixed list of three files from the main branch of
prompts with wget: docs/REPO_POLICIES.md, docs/CODE_STYLEGUIDE.md and
itself. It moves them into place and commits them. It does not push. It
stops before anything is replaced when a fetch fails, when a listed file
has uncommitted changes, and when REPO_POLICIES.md is still at the repo
root. It runs under busybox.

The line-keeping rules, the hash argument and the push are gone. The
policies and checklists say so, and name docs/REPO_POLICIES.md as the
file's place.

Model: opus-5-5
2026-11-18 20:56:57 +00:00
2 changed files with 9 additions and 19 deletions

No files matched your search

+3 -7
View File
@@ -19,7 +19,6 @@ die() {
exit 1 exit 1
} }
main() {
cd "$ROOT" cd "$ROOT"
[ ! -e prompts/REPO_POLICIES.md ] || [ ! -e prompts/REPO_POLICIES.md ] ||
die "this is the prompts repo, where these files come from" die "this is the prompts repo, where these files come from"
@@ -34,9 +33,9 @@ main() {
[ -z "$(git status --porcelain -- $paths)" ] || [ -z "$(git status --porcelain -- $paths)" ] ||
die "commit or discard your changes to these files first:$paths" die "commit or discard your changes to these files first:$paths"
# Every file is fetched before any is replaced. The temporary # Every file is fetched before any is replaced. The temporary directory
# directory is inside the repo so that mv renames: the running script # is inside the repo so that mv renames: the running script is replaced
# is replaced by a new file, never rewritten in place. # by a new file, never rewritten in place.
tmp="$(mktemp -d "$ROOT/.update-policy.XXXXXX")" tmp="$(mktemp -d "$ROOT/.update-policy.XXXXXX")"
trap 'rm -rf "$tmp"' EXIT trap 'rm -rf "$tmp"' EXIT
for entry in $FILES; do for entry in $FILES; do
@@ -58,6 +57,3 @@ main() {
git commit -q -m "Update policy files from prompts" -- $paths git commit -q -m "Update policy files from prompts" -- $paths
echo "update-policy: committed; review it, then push" echo "update-policy: committed; review it, then push"
fi fi
}
main "$@"
+6 -12
View File
@@ -1,8 +1,7 @@
#!/bin/sh #!/bin/sh
# test/update-policy.sh: test script/update-policy on throwaway repos. A # test/update-policy.sh: test script/update-policy on throwaway repos. A
# stub wget serves the files from this checkout, or fails for the path # stub wget serves the files from this checkout, or fails for the path
# in WGET_FAIL, so nothing touches the network. Like wget, it writes a # in WGET_FAIL, so nothing touches the network.
# new file without the execute bit, whatever the source's mode.
set -eu set -eu
PROMPTS="$(cd "$(dirname "$0")/.." && pwd -P)" PROMPTS="$(cd "$(dirname "$0")/.." && pwd -P)"
@@ -26,16 +25,14 @@ while [ "\$#" -gt 1 ]; do
done done
path="\${1#https://git.eeqj.de/sneak/prompts/raw/branch/main/}" path="\${1#https://git.eeqj.de/sneak/prompts/raw/branch/main/}"
[ "\$path" != "\${WGET_FAIL:-}" ] || exit 1 [ "\$path" != "\${WGET_FAIL:-}" ] || exit 1
cat "$PROMPTS/\$path" > "\$output" cp "$PROMPTS/\$path" "\$output"
EOF EOF
chmod +x "$dir/bin/wget" chmod +x "$dir/bin/wget"
PATH="$dir/bin:$PATH" PATH="$dir/bin:$PATH"
export PATH export PATH
# new_repo: a repo with one commit, holding only an older copy of the # new_repo: a repo with one commit, holding only an older copy of the
# script that is shorter than the new one. A run that rewrote the running # script, so that a run must replace the script that is running.
# script in place, instead of replacing it, would then read the new
# file's last lines as commands and fail.
new_repo() { new_repo() {
scenario="$1" scenario="$1"
rm -rf "$dir/repo" rm -rf "$dir/repo"
@@ -44,8 +41,8 @@ new_repo() {
git config user.name test git config user.name test
git config user.email test@example.com git config user.email test@example.com
mkdir script mkdir script
grep -v '^# ' "$PROMPTS/script/update-policy" > script/update-policy cp "$PROMPTS/script/update-policy" script/
chmod +x script/update-policy echo "# older copy" >> script/update-policy
echo own > README.md echo own > README.md
git add README.md script/update-policy git add README.md script/update-policy
git commit -q -m initial git commit -q -m initial
@@ -53,8 +50,6 @@ new_repo() {
new_repo "a first run writes and commits exactly the listed files" new_repo "a first run writes and commits exactly the listed files"
echo stray > stray.txt echo stray > stray.txt
echo staged >> README.md
git add README.md
script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero" script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero"
[ "$(git rev-list --count HEAD)" = 2 ] || fail "made no single commit" [ "$(git rev-list --count HEAD)" = 2 ] || fail "made no single commit"
[ "$(git show --name-only --format= HEAD | sort)" = \ [ "$(git show --name-only --format= HEAD | sort)" = \
@@ -62,8 +57,7 @@ script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero"
cmp -s docs/REPO_POLICIES.md "$PROMPTS/prompts/REPO_POLICIES.md" || cmp -s docs/REPO_POLICIES.md "$PROMPTS/prompts/REPO_POLICIES.md" ||
fail "REPO_POLICIES.md differs" fail "REPO_POLICIES.md differs"
[ -x script/update-policy ] || fail "script not executable" [ -x script/update-policy ] || fail "script not executable"
[ "$(git status --porcelain)" = "$(printf 'M README.md\n?? stray.txt')" ] || [ "$(git status --porcelain)" = "?? stray.txt" ] || fail "tree not clean"
fail "changed files outside the list"
scenario="a second run commits nothing" scenario="a second run commits nothing"
script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero" script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero"