]>
Commit | Line | Data |
---|---|---|
29967ef6 XL |
1 | #!/usr/bin/env bash |
2 | # | |
04454e1e | 3 | # Call `tidy --bless` before git push |
6a06907d | 4 | # Copy this script to .git/hooks to activate, |
29967ef6 XL |
5 | # and remove it from .git/hooks to deactivate. |
6 | # | |
7 | ||
8 | set -Eeuo pipefail | |
9 | ||
10 | # https://github.com/rust-lang/rust/issues/77620#issuecomment-705144570 | |
11 | unset GIT_DIR | |
12 | ROOT_DIR="$(git rev-parse --show-toplevel)" | |
f2b60f7d | 13 | COMMAND="$ROOT_DIR/x.py test tidy" |
29967ef6 XL |
14 | |
15 | if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then | |
16 | COMMAND="python $COMMAND" | |
04454e1e FG |
17 | elif ! command -v python &> /dev/null; then |
18 | COMMAND="python3 $COMMAND" | |
29967ef6 XL |
19 | fi |
20 | ||
5099ac24 | 21 | echo "Running pre-push script '$COMMAND'" |
29967ef6 XL |
22 | |
23 | cd "$ROOT_DIR" | |
24 | ||
25 | $COMMAND |