update-policy: also fetch the style guides for the repo's languages (closes #182)
check / check (push) Successful in 10s
check / check (push) Successful in 10s
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 was merged in pull request #183.
This commit is contained in:
1 parent
d004fd272c
commit
b4f707e565
3 files changed
+78
-7
No files matched your search
+48
-3
@@ -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,44 @@ 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 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 "console.log(1);" > index.js
|
||||
echo "[project]" > pyproject.toml
|
||||
git add package.json index.js 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"
|
||||
|
||||
Reference in new issue
Block a user