Files
aitbc/scripts/git-pre-commit-hook.sh
oib 14d0ed3b44 fix(async): convert PoA proposer methods to async and update coordinator dependencies
- Convert _propose_block, _ensure_genesis_block to async methods in PoAProposer
- Add await to gossip_broker.publish calls in block broadcasting
- Add await to _ensure_genesis_block and _propose_block method calls
- Update coordinator-api Python version constraint to >=3.13,<3.15
- Add torch ^2.10.0 dependency to coordinator-api
- Add make_asgi_app import to prometheus_client in main.py
- Export new routers: global
2026-03-03 15:32:05 +01:00

108 lines
3.4 KiB
Bash
Executable File

#!/bin/bash
# scripts/git-pre-commit-hook.sh
echo "🔍 Checking file locations before commit..."
# Change to project root
cd "$(dirname "$0")/../.."
# Files that should not be at root
ROOT_FORBIDDEN_PATTERNS=(
"test_*.py"
"test_*.sh"
"patch_*.py"
"fix_*.py"
"simple_test.py"
"run_mc_test.sh"
"MULTI_*.md"
)
# Directories that should not be at root
ROOT_FORBIDDEN_DIRS=(
"node_modules"
".pytest_cache"
".ruff_cache"
".venv"
"cli_env"
".vscode"
)
# Check for forbidden files at root
for pattern in "${ROOT_FORBIDDEN_PATTERNS[@]}"; do
if ls $pattern 1> /dev/null 2>&1; then
echo "❌ ERROR: Found files matching '$pattern' at root level"
echo "📁 Suggested location:"
case $pattern in
"test_*.py"|"test_*.sh"|"run_mc_test.sh")
echo " → dev/tests/"
;;
"patch_*.py"|"fix_*.py"|"simple_test.py")
echo " → dev/scripts/"
;;
"MULTI_*.md")
echo " → dev/multi-chain/"
;;
esac
echo "💡 Run: ./scripts/move-to-right-folder.sh --auto"
echo "💡 Or manually: mv $pattern <suggested-directory>/"
exit 1
fi
done
# Check for forbidden directories at root
for dir in "${ROOT_FORBIDDEN_DIRS[@]}"; do
if [[ -d "$dir" && "$dir" != "." && "$dir" != ".." && ! "$dir" =~ ^\.git ]]; then
echo "❌ ERROR: Found directory '$dir' at root level"
echo "📁 Suggested location:"
case $dir in
"node_modules"|".venv"|"cli_env")
echo " → dev/env/"
;;
".pytest_cache"|".ruff_cache"|".vscode")
echo " → dev/cache/"
;;
esac
echo "💡 Run: ./scripts/move-to-right-folder.sh --auto"
echo "💡 Or manually: mv $dir <suggested-directory>/"
exit 1
fi
done
# Check new files being committed
NEW_FILES=$(git diff --cached --name-only --diff-filter=A)
for file in $NEW_FILES; do
dirname=$(dirname "$file")
# Check if file is at root and shouldn't be
if [[ "$dirname" == "." ]]; then
filename=$(basename "$file")
case "$filename" in
test_*.py|test_*.sh)
echo "⚠️ WARNING: Test file '$filename' should be in dev/tests/"
echo "💡 Consider: git reset HEAD $filename && mv $filename dev/tests/ && git add dev/tests/$filename"
;;
patch_*.py|fix_*.py)
echo "⚠️ WARNING: Patch file '$filename' should be in dev/scripts/"
echo "💡 Consider: git reset HEAD $filename && mv $filename dev/scripts/ && git add dev/scripts/$filename"
;;
MULTI_*.md)
echo "⚠️ WARNING: Multi-chain file '$filename' should be in dev/multi-chain/"
echo "💡 Consider: git reset HEAD $filename && mv $filename dev/multi-chain/ && git add dev/multi-chain/$filename"
;;
.aitbc.yaml|.aitbc.yaml.example|.env.production|.nvmrc|.lycheeignore)
echo "⚠️ WARNING: Configuration file '$filename' should be in config/"
echo "💡 Consider: git reset HEAD $filename && mv $filename config/ && git add config/$filename"
;;
esac
fi
done
echo "✅ File location check passed"
exit 0