diff --git a/.githooks/pre-push b/.githooks/pre-push index 92f8d50..d031749 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -9,6 +9,14 @@ set -euo pipefail set -x +COMMIT_HASH=$(git rev-parse HEAD) +CHECKSUM_FILE=".last_unit_tested_commit" + +if [ -f "$CHECKSUM_FILE" ] && [ "$(cat "$CHECKSUM_FILE")" = "$COMMIT_HASH" ]; then + echo "✓ Skipping tests, already tested commit: $COMMIT_HASH" + exit 0 +fi + # Run Mocha directly, fail if any test fails if ! node_modules/.bin/mocha "test/**/*.unit.test.js" "test/**/*.property.test.js"; then echo "Initial test suite failed. Skipping prepush and aborting push." @@ -26,6 +34,9 @@ exit 1 fi +echo "$COMMIT_HASH" > "$CHECKSUM_FILE" +echo "✓ All tests passed for commit: $COMMIT_HASH" + node src/app.js >/dev/null 2>&1 & APP_PID=$!