freeswitch-log-parser 0.12.0

Parser for FreeSWITCH log files — handles compressed .xz files, multi-line dumps, truncated buffers, and stateful UUID/timestamp tracking
Documentation
#!/bin/bash
# Pre-commit hook: Cargo.lock placement, fmt, clippy, tests, gitleaks

set -e

# Cargo.lock belongs only on the detached commit a release tag points at, so a
# release build resolves an exact dependency set while master stays a library
# crate with the lock gitignored. Detached HEAD is the whole signal: on a
# branch, staging it is always the "forgot to git checkout --detach" mistake.
if git diff --cached --name-only --diff-filter=AM | grep -qx 'Cargo.lock'; then
	if git symbolic-ref -q HEAD >/dev/null; then
		echo "Cargo.lock is staged on branch $(git symbolic-ref --short HEAD)."
		echo "It may only be committed on the release tag's own detached commit."
		echo "Run 'git checkout --detach' first, then stage and commit it."
		exit 1
	fi
fi

echo "Running cargo fmt check..."
if ! cargo fmt --all -- --check; then
	echo "Code is not formatted. Run 'cargo fmt --all' to fix."
	exit 1
fi

echo "Running cargo clippy..."
if ! cargo clippy --all-targets --features tui --message-format=short -- -D warnings; then
	echo "Clippy found warnings. Fix them before committing."
	exit 1
fi

echo "Running tests..."
if ! test_output=$(cargo test --release --features tui 2>&1); then
	echo "$test_output" | tail
	echo "Tests failed. Fix them before committing."
	exit 1
fi

echo "Running gitleaks..."
# --staged scans exactly what is about to be committed; `detect` only scans
# already-committed history and lets staged secrets through (it did once).
# .gitleaks.local.toml extends the committed config with private patterns
# and is never committed itself (.git/info/exclude).
GITLEAKS_ARGS=()
if [ -f .gitleaks.local.toml ]; then
	GITLEAKS_ARGS=(--config .gitleaks.local.toml)
fi
if ! gitleaks git --staged --no-banner "${GITLEAKS_ARGS[@]}"; then
	echo "gitleaks detected secrets in the staged changes. Remove them before committing."
	exit 1
fi

echo "Pre-commit checks passed"