The home for Hyperlane core contracts, sdk packages, and other infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hyperlane-monorepo/pre-commit.sh

56 lines
889 B

#!/bin/sh
# Stash uncommitted changes
STASH_NAME="pre-commit-$(date +%s)"
git stash save -q --keep-index $STASH_NAME
abort()
{
echo >&2 '
***************
*** ABORTED ***
***************
'
echo "An error occurred. Please review your code and try again" >&2
exit 1
}
trap 'abort' 0
set -e
git update-index -q --refresh
if ! git diff-index --quiet HEAD -- ./solidity/optics-core; then
cd solidity/optics-core
npm test
npm run lint
cd ../..
fi
if ! git diff-index --quiet HEAD -- ./solidity/optics-bridge; then
cd solidity/optics-bridge
npm test
npm run lint
cd ../..
fi
cd ./rust
echo '+cargo test'
cargo test
echo '+cargo clippy -- -D warnings'
cargo clippy -- -D warnings
echo '+cargo fmt -- --check'
cargo fmt -- --check
cd ..
trap : 0
trap : 0
echo >&2 '
************
*** DONE ***
************
'
git stash apply stash^{/$STASH_NAME}