systab/.githooks/pre-commit
Matthias Johnson 8e45f7917c Add -X delete operation, demo tape tests, and consolidate demos
- Add -X <id|name> to stop, disable, and remove a job's unit files;
  mutually exclusive with all other management options; 13 new tests
- Add demo/test-tapes.sh to verify all VHS tape commands run cleanly;
  wired into pre-commit hook alongside test.sh (combined badge count)
- Rename demo job names to *_home variants to avoid clashing with real
  user jobs; add per-tape preflight cleanup via -X
- Consolidate four demo GIFs into quickstart + all-features + editmode
  screenshot; remove notifications/services tapes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 01:02:13 -07:00

50 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
badge_file="badges/tests.json"
write_badge() {
local status="$1" color="$2"
mkdir -p badges
cat > "$badge_file" <<EOF
{
"schemaVersion": 1,
"label": "tests",
"message": "$status",
"color": "$color"
}
EOF
git add "$badge_file"
}
echo "Running ShellCheck..."
if ! shellcheck systab; then
write_badge "failing" "red"
echo "ShellCheck failed — commit blocked."
exit 1
fi
echo "Running tests..."
if output=$(./test.sh 2>&1); then
echo "$output"
test_count=$(grep -oP '\d+(?= passed)' <<< "$output" | tail -1)
else
echo "$output"
write_badge "failing" "red"
echo "Tests failed — commit blocked."
exit 1
fi
echo "Running demo tape tests..."
if tape_output=$(./demo/test-tapes.sh 2>&1); then
echo "$tape_output"
tape_count=$(grep -oP '\d+(?= passed)' <<< "$tape_output" | tail -1)
else
echo "$tape_output"
write_badge "failing" "red"
echo "Demo tape tests failed — commit blocked."
exit 1
fi
total_count=$(( ${test_count:-0} + ${tape_count:-0} ))
write_badge "${total_count} passed" "brightgreen"