diff --git a/.githooks/pre-push b/.githooks/pre-push index a7e920f..20d2baf 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -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: +# +# 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"