rust/src/etc/pre-commit.sh

24 lines
514 B
Bash
Raw Permalink Normal View History

2020-10-06 01:35:06 +02:00
#!/usr/bin/env bash
#
# Call `tidy --bless` before each commit
2021-02-25 00:37:13 +01:00
# Copy this script to .git/hooks to activate,
2020-10-06 00:57:48 +02:00
# and remove it from .git/hooks to deactivate.
#
2020-10-06 00:57:48 +02:00
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 --bless"
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
COMMAND="python $COMMAND"
fi
echo "Running pre-commit script '$COMMAND'"
2020-10-06 01:35:06 +02:00
cd "$ROOT_DIR"
$COMMAND