diff --git a/.githooks/pre-push b/.githooks/pre-push new file mode 100755 index 0000000..a585bf6 --- /dev/null +++ b/.githooks/pre-push @@ -0,0 +1,21 @@ +#!/bin/sh +# Run the repository's CI before every push, so a failure surfaces here instead of in the merge queue. +# Delete this hook once this repository's kixel.quest merge queue is live. +set -e +# A push that only deletes refs carries no commits to check. +pushes=false +while read -r _ sha _ _; do + case $sha in *[!0]*) pushes=true ;; esac +done +$pushes || exit 0 +# A branch from before the recipe, which pull request CI still checks, has none to run. +if ! grep -Eq '^ci([[:space:]]|:)' justfile 2>/dev/null; then + echo "pre-push: this checkout has no just ci recipe; merge the default branch to check pushes here" >&2 + exit 0 +fi +# A linked worktree's push hands the hook its GIT_DIR, which would send a test's scratch repository's git commands to this one. +for var in $(git rev-parse --local-env-vars); do unset "$var"; done +if [ -f flake.nix ]; then + exec nix develop --command just ci +fi +exec just ci