agent/claude/code/scripts/check-coverage.sh

23 lines
648 B
Bash
Raw Normal View History

#!/bin/bash
# Check for a drop in test coverage.
set -e
# Source the main coverage script to use its functions
source claude/code/commands/coverage.sh
# Read the input from the hook system
read -r input
# Get current and previous coverage
CURRENT_COVERAGE=$(get_current_coverage)
PREVIOUS_COVERAGE=$(get_previous_coverage)
# Compare coverage and print warning to stderr
if awk -v current="$CURRENT_COVERAGE" -v previous="$PREVIOUS_COVERAGE" 'BEGIN {exit !(current < previous)}'; then
echo "⚠️ Test coverage dropped from $PREVIOUS_COVERAGE% to $CURRENT_COVERAGE%" >&2
fi
# Pass the original input through to the next hook
echo "$input"