mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 17:43:05 +02:00
- scripts/optimize_vscode.py: auto-detect hardware (CPU, RAM, GPU, disk) and apply optimal VS Code settings and Electron GPU flags - scripts/pytest_changed_packages.py: pre-commit hook that runs pytest only for python_pkg subpackages with changed files - .pre-commit-config.yaml: use new selective pytest hook - scripts/check_python_location.sh: allow scripts/ directory
44 lines
1.2 KiB
Bash
Executable File
44 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Check that all Python files are under python_pkg/.
|
|
# Exceptions: linux_configuration/, pomodoro_app/, sonic_pi/, Bash/,
|
|
# and vendored/generated directories.
|
|
# Used as a pre-commit hook; receives staged file paths as arguments.
|
|
|
|
set -uo pipefail
|
|
|
|
# Directories allowed to contain Python files outside python_pkg/
|
|
ALLOWED_DIRS="linux_configuration/|pomodoro_app/|sonic_pi/|scripts/"
|
|
|
|
errors=()
|
|
|
|
for file in "$@"; do
|
|
# Only check .py files
|
|
[[ "$file" != *.py ]] && continue
|
|
|
|
# Skip files already under python_pkg/
|
|
[[ "$file" == python_pkg/* ]] && continue
|
|
|
|
# Skip allowed directories (non-Python projects with some Python scripts)
|
|
if echo "$file" | grep -qE "^($ALLOWED_DIRS)"; then
|
|
continue
|
|
fi
|
|
|
|
# Skip vendored/generated directories
|
|
if echo "$file" | grep -qE '(^|/)(\.venv|venv|__pycache__|build|dist|node_modules|\.git)/'; then
|
|
continue
|
|
fi
|
|
|
|
errors+=("$file")
|
|
done
|
|
|
|
if [[ ${#errors[@]} -gt 0 ]]; then
|
|
echo "ERROR: Python files must be under python_pkg/."
|
|
echo "The following files are in the wrong location:"
|
|
for err in "${errors[@]}"; do
|
|
echo " $err"
|
|
done
|
|
echo ""
|
|
echo "Move them with: git mv <file> python_pkg/<file>"
|
|
exit 1
|
|
fi
|