Files
OwnCord/.githooks/pre-push
T
Claude fc0f86118c chore: add Claude Code project config, git hooks, and session setup
- CLAUDE.md (root + Server + client) documenting commands, generated-code
  rules, and the known-red client unit suite policy
- .claude/skills: ci-check (local CI mirror), protocol-change, db-change
  workflows for the sqlc/protocol codegen invariants CI enforces
- .githooks pre-commit/pre-push mirroring CI's fast gates (gofmt, go vet,
  oxlint, prettier, tsc, tag-variant builds, sqlc/protocol staleness),
  enabled via 'npm run hooks:install'
- .claude SessionStart hook installing client npm deps and warming the Go
  module cache so remote sessions can run tests/linters immediately
- .mcp.json with Playwright and Context7 MCP servers
- .gitignore: commit shared Claude config; keep local-only overrides ignored

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BDcVJqGjHcJVLoV4x1HFjW
2026-07-19 16:54:13 +00:00

62 lines
2.2 KiB
Bash
Executable File

#!/bin/sh
# OwnCord pre-push hook — build-level gates that mirror CI's expensive-but-common
# failure modes (tag-variant compiles, typecheck, type-aware lint).
#
# Bypass: git push --no-verify or OWNCORD_SKIP_HOOKS=1
# Extra: OWNCORD_PREPUSH_TESTS=1 additionally runs the server test suite (-race).
[ "${OWNCORD_SKIP_HOOKS:-0}" = "1" ] && exit 0
repo_root=$(git rev-parse --show-toplevel) || exit 1
cd "$repo_root" || exit 1
fail() {
printf '\npre-push: FAIL: %s\n(bypass with --no-verify; CI will still enforce this)\n' "$1" >&2
exit 1
}
# What changed relative to origin/main decides which side's gates run.
# Markdown/docs changes never trigger builds.
changed=$(git diff --name-only origin/main...HEAD 2>/dev/null) || changed="__all__"
[ "$changed" = "__all__" ] || changed=$(printf '%s\n' "$changed" | grep -v '\.md$')
[ -z "$changed" ] && exit 0
server_changed=0
client_changed=0
if [ "$changed" = "__all__" ]; then
server_changed=1
client_changed=1
else
if printf '%s\n' "$changed" | grep -q '^Server/'; then server_changed=1; fi
if printf '%s\n' "$changed" | grep -q '^Client/tauri-client/'; then client_changed=1; fi
if printf '%s\n' "$changed" | grep -q '^docs/protocol-schema\.json'; then
server_changed=1
client_changed=1
fi
fi
if [ "$server_changed" = 1 ] && command -v go >/dev/null 2>&1; then
echo "pre-push: server build (all tag variants)..."
(cd Server \
&& go build ./... \
&& go build -tags otel ./... \
&& go build -tags wazero ./... \
&& go build -tags otel,wazero ./...) || fail "server build (a tag variant failed to compile)"
if [ "${OWNCORD_PREPUSH_TESTS:-0}" = "1" ]; then
echo "pre-push: server tests (-race)..."
(cd Server && go test -race ./...) || fail "server tests"
fi
fi
if [ "$client_changed" = 1 ]; then
if [ -d Client/tauri-client/node_modules ]; then
echo "pre-push: client typecheck + eslint..."
(cd Client/tauri-client && npm run -s typecheck) || fail "tsc --noEmit"
(cd Client/tauri-client && npx eslint src/) || fail "eslint"
else
printf 'pre-push: WARNING: node_modules missing in Client/tauri-client; skipping client checks.\n' >&2
fi
fi
exit 0