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
20 changes: 20 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
#!/usr/bin/env bash
# Pre-push hook — runs all check scripts before allowing a push.
# Install with: git config core.hooksPath .githooks
#
# git feeds one line per ref being pushed on stdin:
# <local ref> <local sha> <remote ref> <remote sha>
# A branch deletion has local ref "(delete)" and an all-zero local sha. Deletes
# push no commits, so there is nothing to lint or signature-check — skip the
# checks when every ref is a delete (or nothing is being pushed at all).
set -euo pipefail

REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
ZERO_SHA="0000000000000000000000000000000000000000"

pushing_commits=0
while read -r _local_ref local_sha _remote_ref _remote_sha; do
if [ "$local_sha" != "$ZERO_SHA" ]; then
pushing_commits=1
fi
done

if [ "$pushing_commits" -eq 0 ]; then
exit 0
fi

exec "$REPO_ROOT/scripts/runChecks.sh"