Files
aitbc/scripts/utils/git-pre-commit-hook.sh
aitbc1 bfe6f94b75
Some checks failed
AITBC CI/CD Pipeline / lint-and-test (3.11) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.12) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.13) (push) Has been cancelled
AITBC CI/CD Pipeline / test-cli (push) Has been cancelled
AITBC CI/CD Pipeline / test-services (push) Has been cancelled
AITBC CI/CD Pipeline / test-production-services (push) Has been cancelled
AITBC CI/CD Pipeline / security-scan (push) Has been cancelled
AITBC CI/CD Pipeline / build (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-staging (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-production (push) Has been cancelled
AITBC CI/CD Pipeline / performance-test (push) Has been cancelled
AITBC CI/CD Pipeline / docs (push) Has been cancelled
AITBC CI/CD Pipeline / release (push) Has been cancelled
AITBC CI/CD Pipeline / notify (push) Has been cancelled
Security Scanning / Bandit Security Scan (apps/coordinator-api/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (cli/aitbc_cli) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-core/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-crypto/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-sdk/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (tests) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (javascript) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (python) (push) Has been cancelled
Security Scanning / Dependency Security Scan (push) Has been cancelled
Security Scanning / Container Security Scan (push) Has been cancelled
Security Scanning / OSSF Scorecard (push) Has been cancelled
Security Scanning / Security Summary Report (push) Has been cancelled
AITBC CLI Level 1 Commands Test / test-cli-level1 (3.11) (push) Has been cancelled
AITBC CLI Level 1 Commands Test / test-cli-level1 (3.12) (push) Has been cancelled
AITBC CLI Level 1 Commands Test / test-cli-level1 (3.13) (push) Has been cancelled
AITBC CLI Level 1 Commands Test / test-summary (push) Has been cancelled
chore: remove outdated documentation and reference files
- Remove debugging service documentation (DEBUgging_SERVICES.md)
- Remove development logs policy and quick reference guides
- Remove E2E test creation summary
- Remove gift certificate example file
- Remove GitHub pull summary documentation
2026-03-25 12:56:07 +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