EmboFlow/.githooks/pre-push

20 lines
747 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
repo_root="$(git rev-parse --show-toplevel)"
cd "$repo_root"
if git rev-parse --abbrev-ref --symbolic-full-name "@{upstream}" >/dev/null 2>&1; then
base_ref="$(git rev-parse --abbrev-ref --symbolic-full-name "@{upstream}")"
python3 scripts/check_doc_code_sync.py . --base-ref "$base_ref" --strict
python3 scripts/check_commit_message.py --rev-range "$base_ref..HEAD"
elif git rev-parse HEAD~1 >/dev/null 2>&1; then
python3 scripts/check_doc_code_sync.py . --base-ref HEAD~1 --strict
python3 scripts/check_commit_message.py --rev-range "HEAD~1..HEAD"
else
python3 scripts/check_doc_code_sync.py . --rev-range HEAD --strict
python3 scripts/check_commit_message.py --rev-range HEAD
fi
make test