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

+36 -3
View File
@@ -51,14 +51,21 @@ new_repo() {
git commit -q -m initial
}
new_repo "a first run writes and commits exactly the listed files"
# committed_files_are: check that the last commit holds the listed files
# and the ones given, and no others.
committed_files_are() {
[ "$(git show --name-only --format= HEAD | sort)" = \
"$(echo "$LISTED $*" | tr ' ' '\n' | grep . | sort)" ] ||
fail "commit holds the wrong files"
}
new_repo "a first run, with no language files, commits exactly the listed files"
echo stray > stray.txt
echo staged >> README.md
git add README.md
script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero"
[ "$(git rev-list --count HEAD)" = 2 ] || fail "made no single commit"
[ "$(git show --name-only --format= HEAD | sort)" = \
"$(echo "$LISTED" | tr ' ' '\n' | sort)" ] || fail "commit holds other files"
committed_files_are
cmp -s docs/REPO_POLICIES.md "$PROMPTS/prompts/REPO_POLICIES.md" ||
fail "REPO_POLICIES.md differs"
[ -x script/update-policy ] || fail "script not executable"
@@ -70,6 +77,32 @@ script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero"
[ "$(git rev-list --count HEAD)" = 2 ] || fail "made a commit"
grep -q "nothing to commit" "$dir/output" || fail "did not say so"
new_repo "a Go repo that uses net/http also gets the Go guide and HTTP conventions"
echo "module example.com/app" > go.mod
printf 'package main\n\nimport "net/http"\n' > main.go
git add go.mod main.go
git commit -q -m go
script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero"
committed_files_are docs/CODE_STYLEGUIDE_GO.md docs/GO_HTTP_SERVER_CONVENTIONS.md
cmp -s docs/CODE_STYLEGUIDE_GO.md "$PROMPTS/prompts/CODE_STYLEGUIDE_GO.md" ||
fail "CODE_STYLEGUIDE_GO.md differs"
new_repo "a Go repo without net/http gets only the Go guide"
echo "module example.com/app" > go.mod
printf 'package main\n\nimport "fmt"\n' > main.go
git add go.mod main.go
git commit -q -m go
script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero"
committed_files_are docs/CODE_STYLEGUIDE_GO.md
new_repo "a repo with package.json and pyproject.toml gets the JS and Python guides"
echo "{}" > package.json
echo "[project]" > pyproject.toml
git add package.json pyproject.toml
git commit -q -m js-and-python
script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero"
committed_files_are docs/CODE_STYLEGUIDE_JS.md docs/CODE_STYLEGUIDE_PYTHON.md
new_repo "a failed fetch writes nothing"
WGET_FAIL=prompts/CODE_STYLEGUIDE.md script/update-policy > "$dir/output" 2>&1 &&
fail "exited zero"