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

A go.mod adds the Go guide, plus the Go HTTP server conventions when a
tracked .go file imports net/http. Tracked .js or .ts files add 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 03:25:18 +00:00
1 parent d004fd272c
commit 87ccb3e7e3
3 files changed
+78 -7

No files matched your search

+24 -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,25 @@ prompts/CODE_STYLEGUIDE.md:docs/CODE_STYLEGUIDE.md
script/update-policy:script/update-policy
"
# The style guide for each language the repo uses, and the HTTP server
# conventions for Go code using net/http. Go and Python are found by
# their file at the root, JavaScript by tracked .js or .ts files: many
# Go repos have a package.json only to pin prettier.
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 [ -n "$(git ls-files -- '*.js' '*.ts')" ]; 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 +47,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#*:}"