rust/src/etc/pre-push.sh
Joshua Nelson 9d664b24f9 Make the pre-commit script pre-push instead
This should make it substantially less annoying, and hopefully more
people will find it useful. In particular, it will no longer run tidy
each time you run `git commit --amend` or rebase a branch.

This also warns if you have the old script in pre-commit; see the HACK
comment for details.
2021-08-24 19:55:07 -05:00

23 lines
512 B
Bash
Executable file

#!/usr/bin/env bash
#
# Call `tidy --bless` before each commit
# 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 --bless"
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
COMMAND="python $COMMAND"
fi
echo "Running pre-push script '$COMMAND'"
cd "$ROOT_DIR"
$COMMAND