1 Commits
Author SHA1 Message Date
sneak 87ccb3e7e3 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
2026-11-19 03:25:18 +00:00
3 changed files with 20 additions and 6 deletions

No files matched your search

+1 -1
View File
@@ -165,7 +165,7 @@ style conventions are in separate documents:
- `script/update-policy` itself, so the script stays current - `script/update-policy` itself, so the script stays current
- `docs/CODE_STYLEGUIDE_GO.md`, when the repo has a `go.mod` - `docs/CODE_STYLEGUIDE_GO.md`, when the repo has a `go.mod`
- `docs/GO_HTTP_SERVER_CONVENTIONS.md`, when its Go code imports `net/http` - `docs/GO_HTTP_SERVER_CONVENTIONS.md`, when its Go code imports `net/http`
- `docs/CODE_STYLEGUIDE_JS.md`, when the repo has a `package.json` - `docs/CODE_STYLEGUIDE_JS.md`, when the repo tracks `.js` or `.ts` files
- `docs/CODE_STYLEGUIDE_PYTHON.md`, when the repo has a `pyproject.toml` or - `docs/CODE_STYLEGUIDE_PYTHON.md`, when the repo has a `pyproject.toml` or
`setup.py` `setup.py`
+5 -3
View File
@@ -15,8 +15,10 @@ prompts/CODE_STYLEGUIDE.md:docs/CODE_STYLEGUIDE.md
script/update-policy:script/update-policy script/update-policy:script/update-policy
" "
# The style guide for each language the repo uses, found by its file at # The style guide for each language the repo uses, and the HTTP server
# the root, and the HTTP server conventions for Go code using net/http. # 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() { language_files() {
if [ -e go.mod ]; then if [ -e go.mod ]; then
echo prompts/CODE_STYLEGUIDE_GO.md:docs/CODE_STYLEGUIDE_GO.md echo prompts/CODE_STYLEGUIDE_GO.md:docs/CODE_STYLEGUIDE_GO.md
@@ -24,7 +26,7 @@ language_files() {
echo prompts/GO_HTTP_SERVER_CONVENTIONS.md:docs/GO_HTTP_SERVER_CONVENTIONS.md echo prompts/GO_HTTP_SERVER_CONVENTIONS.md:docs/GO_HTTP_SERVER_CONVENTIONS.md
fi fi
fi fi
if [ -e package.json ]; then if [ -n "$(git ls-files -- '*.js' '*.ts')" ]; then
echo prompts/CODE_STYLEGUIDE_JS.md:docs/CODE_STYLEGUIDE_JS.md echo prompts/CODE_STYLEGUIDE_JS.md:docs/CODE_STYLEGUIDE_JS.md
fi fi
if [ -e pyproject.toml ] || [ -e setup.py ]; then if [ -e pyproject.toml ] || [ -e setup.py ]; then
+14 -2
View File
@@ -95,10 +95,22 @@ git commit -q -m go
script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero" script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero"
committed_files_are docs/CODE_STYLEGUIDE_GO.md committed_files_are docs/CODE_STYLEGUIDE_GO.md
new_repo "a repo with package.json and pyproject.toml gets the JS and Python guides" new_repo "a Go repo with a package.json only for prettier gets no JS guide"
echo "module example.com/app" > go.mod
printf 'package main\n\nimport "fmt"\n' > main.go
echo '{"devDependencies": {"prettier": "3.3.3"}}' > package.json
mkdir -p .yarn/releases
echo "// yarn" > .yarn/releases/yarn-4.5.0.cjs
git add go.mod main.go package.json .yarn/releases/yarn-4.5.0.cjs
git commit -q -m go-with-prettier
script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero"
committed_files_are docs/CODE_STYLEGUIDE_GO.md
new_repo "a repo with .js files and pyproject.toml gets the JS and Python guides"
echo "{}" > package.json echo "{}" > package.json
echo "console.log(1);" > index.js
echo "[project]" > pyproject.toml echo "[project]" > pyproject.toml
git add package.json pyproject.toml git add package.json index.js pyproject.toml
git commit -q -m js-and-python git commit -q -m js-and-python
script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero" script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero"
committed_files_are docs/CODE_STYLEGUIDE_JS.md docs/CODE_STYLEGUIDE_PYTHON.md committed_files_are docs/CODE_STYLEGUIDE_JS.md docs/CODE_STYLEGUIDE_PYTHON.md