summaryrefslogtreecommitdiffstats
path: root/src/etc/pre-push.sh
blob: be7de3ebaf5712979fc6976b8a2edd4b1693d8e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env bash
#
# Call `tidy --bless` before git push
# Copy this script to .git/hooks to activate,
# and remove it from .git/hooks to deactivate.
#

set -Eeuo pipefail

# https://github.com/rust-lang/rust/issues/77620#issuecomment-705144570
unset GIT_DIR
ROOT_DIR="$(git rev-parse --show-toplevel)"
COMMAND="$ROOT_DIR/x.py test tidy"

if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
  COMMAND="python $COMMAND"
elif ! command -v python &> /dev/null; then
  COMMAND="python3 $COMMAND"
fi

echo "Running pre-push script '$COMMAND'"

cd "$ROOT_DIR"

$COMMAND