Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .githooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ while read -r _ sha _ _; do
echo "pre-push: pushing $sha but HEAD is $head; check out the branch you push" >&2
exit 1
done
if [[ -n $(git status --porcelain) ]]; then
# Its own line, so set -e refuses the push when status itself fails.
status=$(git status --porcelain)
if [[ -n $status ]]; then
echo "pre-push: uncommitted changes; commit or stash them so the check tests what is pushed" >&2
exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions docs/repo-standards.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ Use only GitHub's default labels and labels added by Dependabot.
- Install with `npm ci`, never `npm install`. OpenClaw plugin repos use `npm ci --ignore-scripts`.
- Keep scripts in lowercase `scripts/`. Don't add a second task runner. An existing Makefile or justfile calls `scripts/check`.
- Every repo with `scripts/check` has a committed `.githooks/pre-push` that runs it, copied byte for byte from [splitleafhq/.github](https://github.com/splitleafhq/.github/blob/main/.githooks/pre-push). It refuses a push whose commit isn't `HEAD` (an annotated tag counts by the commit it names) and a push from a tree with uncommitted changes, so the check tests what is pushed. Turn it on once per clone with `git config core.hooksPath .githooks`, and never skip it. Change the hook here first, where `scripts/test-pre-push` tests it, then copy it out; never edit a copy. No hook frameworks: lefthook skips its pre-push jobs when `HEAD` has no diff from `@{push}` ([evilmartians/lefthook#1612](https://github.com/evilmartians/lefthook/issues/1612)).
- `scripts/check` has two routes at most: a push whose changed files are all Markdown may skip slow steps, and every other push runs everything. No other path routes; each one is a claim that some files can't break some tests, and nothing checks it. The portable part CI runs in an Xcode app (below) is CI's subset, not a route.
- A step whose tool or dependency is missing fails. It never warns and passes, and tests never skip for a missing dependency: install it, or the check fails.
- `scripts/check` has two routes at most: a push whose changed files are all Markdown may skip slow steps, and every other push runs everything. No other path routes; each one is a claim that some files can't break some tests, and nothing checks it. An empty, unknown or failed diff runs everything, and Markdown that a check reads (generated from, linted, or loaded at run time) is not doc-only. The portable part CI runs in an Xcode app (below) is CI's subset, not a route.
- Every test the full check needs runs: a missing tool or test prerequisite fails the check, never warns and passes, and a test never skips itself because a dependency is absent. Provision test dependencies (venvs, binaries, local fixtures), not live services. A suite that truly can't run on every push is named in `scripts/check` as a separate opt-in, not skipped silently.
- `scripts/check` runs every test suite the repo has: every package's tests, and in an Xcode app every test target `xcodebuild -list` shows. The pull request that adds a suite adds it to `scripts/check`.
- A pull request that changes `scripts/check` or the hook proves each changed step can fail: commit a change that breaks it, run `git push --dry-run origin HEAD:refs/heads/probe` (it runs the pre-push hook and pushes nothing), expect a nonzero exit naming that step, then drop the commit. An uncommitted change proves nothing: the hook refuses a dirty tree before the check runs.
- Xcode apps: `scripts/check` is the full local check, macOS build and tests included. CI runs a named portable part of it on Linux, like `scripts/check --portable`.
Expand Down
3 changes: 3 additions & 0 deletions scripts/test-pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ case_ "annotated tag on HEAD~1" nonzero skipped "pre-push: pushing .* but HEAD i
touch untracked
case_ "untracked file" nonzero skipped "pre-push: uncommitted changes" push origin main:refs/heads/dirty
rm untracked
cp .git/index "$tmp/index" && echo corrupt > .git/index
case_ "unreadable index" nonzero skipped "" push origin main:refs/heads/corrupt
cp "$tmp/index" .git/index
case_ "failing check refuses the push" nonzero ran "" env STUB_RC=1 "${git[@]}" push origin main:refs/heads/red
case_ "push --dry-run runs the hook" nonzero ran "" env STUB_RC=1 "${git[@]}" push --dry-run origin main:refs/heads/probe
"${git[@]}" worktree add -q "$tmp/linked" -b linked
Expand Down
Loading