update-policy: also fetch the style guides for the repo's languages (closes #182)
check / check (push) Successful in 22s

A go.mod adds the Go guide, plus the Go HTTP server conventions when a
tracked .go file imports net/http. A package.json adds the JS guide; a
pyproject.toml or setup.py adds the Python guide. Each goes to docs/.

Model: opus-5-5
This commit is contained in:
sneak committed 2026-11-19 02:56:58 +00:00
1 parent d004fd272c
commit 9862d2b52a
3 files changed
+64 -7

No files matched your search

+22 -3
View File
@@ -1,7 +1,8 @@
#!/bin/sh
# script/update-policy: replace the files below with their current
# versions from the main branch of the prompts repo, and commit them. It
# does not push. Identical in all repos, and it updates itself.
# script/update-policy: replace the files below, and the style guides
# for the repo's languages, with their current versions from the main
# branch of the prompts repo, and commit them. It does not push.
# Identical in all repos, and it updates itself.
set -eu
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
@@ -14,6 +15,23 @@ prompts/CODE_STYLEGUIDE.md:docs/CODE_STYLEGUIDE.md
script/update-policy:script/update-policy
"
# The style guide for each language the repo uses, found by its file at
# the root, and the HTTP server conventions for Go code using net/http.
language_files() {
if [ -e go.mod ]; then
echo prompts/CODE_STYLEGUIDE_GO.md:docs/CODE_STYLEGUIDE_GO.md
if git grep -q '"net/http"' -- '*.go'; then
echo prompts/GO_HTTP_SERVER_CONVENTIONS.md:docs/GO_HTTP_SERVER_CONVENTIONS.md
fi
fi
if [ -e package.json ]; then
echo prompts/CODE_STYLEGUIDE_JS.md:docs/CODE_STYLEGUIDE_JS.md
fi
if [ -e pyproject.toml ] || [ -e setup.py ]; then
echo prompts/CODE_STYLEGUIDE_PYTHON.md:docs/CODE_STYLEGUIDE_PYTHON.md
fi
}
die() {
echo "update-policy: $*" >&2
exit 1
@@ -27,6 +45,7 @@ main() {
die "REPO_POLICIES.md is at the root;" \
"move it into docs/ with git mv and fix the links to it first"
FILES="$FILES $(language_files)"
paths=""
for entry in $FILES; do
paths="$paths ${entry#*:}"