Replace script/update-policy with script/write-upstream-policy-files and script/commit-upstream-policy-files (closes #165)
check / check (push) Successful in 1m56s
check / check (push) Successful in 1m56s
script/write-upstream-policy-files fetches the shared policy files from prompts over HTTP and writes them into a repo clone, or into its own repo. It commits nothing. It keeps a repo's own entries in .gitignore, .dockerignore, .editorconfig and .golangci.yml. It stops before writing when one of those files, or a repo's own script of the same name, has a line it cannot keep. script/commit-upstream-policy-files replaces script/update-policy. It fetches the current script/write-upstream-policy-files, runs it on its own repo and commits the result without pushing. make commit-upstream-policy-files replaces make update-policy. test/commit-upstream-policy-files.sh replaces test/update-policy.sh. The Dockerfile's test stage runs it with no timeout, with coreutils so that cp is GNU cp. Model: opus-5-5
This commit is contained in:
1 parent
964d973e3c
commit
3601ebf2a1
11 files changed
+1348
-825
No files matched your search
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
# script/commit-upstream-policy-files: bring this repo up to standards.
|
||||
# It fetches the current script/write-upstream-policy-files 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)"
|
||||
WRITE_UPSTREAM_POLICY_FILES_URL="https://git.eeqj.de/sneak/prompts/raw/branch/main/script/write-upstream-policy-files"
|
||||
|
||||
die() {
|
||||
echo "commit-upstream-policy-files: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
main() {
|
||||
[ "$#" -eq 0 ] || die "usage: script/commit-upstream-policy-files"
|
||||
|
||||
cd "$ROOT"
|
||||
|
||||
tmp="$(mktemp -d)"
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
|
||||
curl --fail --silent --show-error --max-time 60 \
|
||||
--output "$tmp/write-upstream-policy-files" \
|
||||
"$WRITE_UPSTREAM_POLICY_FILES_URL" ||
|
||||
die "cannot fetch $WRITE_UPSTREAM_POLICY_FILES_URL"
|
||||
|
||||
sh "$tmp/write-upstream-policy-files" "$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 "commit-upstream-policy-files: already at prompts $commit, nothing to commit"
|
||||
else
|
||||
git commit -m "Update policy files from prompts $commit" -- $paths
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in new issue
Block a user