Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash

set -u

echo "===== PRE-COMMIT CHECKS ====="

REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null)" || {
echo "Pre-commit hook requires a real git clone/worktree."
exit 1
}

cd "$REPO_ROOT" || exit 1

if command -v python3 >/dev/null 2>&1; then
PYTHON_BIN="python3"
elif command -v python >/dev/null 2>&1; then
PYTHON_BIN="python"
else
echo "Python not found in PATH."
exit 1
fi

if [ -f "$REPO_ROOT/common/acs_test_framework_runner/report.py" ]; then
REPORT_SCRIPT="$REPO_ROOT/common/acs_test_framework_runner/report.py"

else
echo "report.py not found."
echo "Checked:"
echo " - $REPO_ROOT/common/acs_test_framework_runner/report.py"
exit 1
fi

HOOK_LOG_DIR="$REPO_ROOT/common/reports"
HOOK_LOG="$HOOK_LOG_DIR/precommit_report.log"

mkdir -p "$HOOK_LOG_DIR"

"$PYTHON_BIN" "$REPORT_SCRIPT" 2>&1 | tee "$HOOK_LOG"
STATUS=${PIPESTATUS[0]}


if [ "$STATUS" -ne 0 ]; then
echo "Pre-commit checks failed."
echo "Log saved at: $HOOK_LOG"
exit 1
fi

echo "All checks passed. Proceeding with commit."
exit 0
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

__pycache__/
*.py[cod]

common/reports/
reports/
__pycache__/
*.py[cod]

pylint_recent.log
Loading
Loading