Skip to content
Merged
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
43 changes: 41 additions & 2 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
#!/bin/sh
# Checks only what this push changes against its merge base with origin/staging (the PR base):
# biome format + lint on the changed files, then type-check for the affected workspaces.
# CI runs the full lint, type-check and audit gate on every PR, so it stays the backstop.
set -e

bun run lint:check
bun run type-check
# git passes one "<local ref> <local sha> <remote ref> <remote sha>" line per pushed ref.
zero=0000000000000000000000000000000000000000
head=$(git rev-parse HEAD)
pushes_head=false
while read -r _local_ref local_sha _remote_ref _remote_sha; do
[ "$local_sha" = "$zero" ] && continue
if [ "$local_sha" != "$head" ]; then
# These checks read the working tree, which holds HEAD, not this commit.
echo "pre-push: $local_sha is not the checked-out commit; leaving it to CI"
continue
fi
pushes_head=true
done
[ "$pushes_head" = true ] || exit 0

base=$(git merge-base HEAD origin/staging 2>/dev/null || true)
if [ -z "$base" ]; then
echo "pre-push: origin/staging not found, running the full lint and type-check"
bun run lint:check
bun run type-check
exit 0
fi

# Deletions still decide the type-check (an import of a deleted module breaks); biome only
# reads files that exist.
changed=$(git diff --name-only "$base" HEAD)
[ -z "$changed" ] && exit 0
existing=$(git diff --name-only --diff-filter=ACMR "$base" HEAD)

if [ -n "$existing" ]; then
# Word-splitting the list is deliberate; no path biome checks contains a space.
bunx biome check --no-errors-on-unmatched --files-ignore-unknown=true $existing
fi

if printf '%s\n' "$changed" | grep -qE '^scripts/'; then
bun run type-check:scripts:esm
fi
TURBO_SCM_BASE="$base" bunx turbo run type-check --affected --output-logs=errors-only
Loading