mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-29 21:03:40 +00:00
Set up pytest with Home Assistant support and created 6 tests for midnight-crossing period logic (5 unit tests + 1 integration test). Added pytest configuration, test dependencies, test runner script (./scripts/test), and comprehensive tests for group_periods_by_day() and midnight turnover consistency. All tests pass in 0.12s. Impact: Provides regression testing for midnight-crossing period bugs. Tests validate periods remain visible across midnight turnover.
89 lines
2.5 KiB
Bash
Executable file
89 lines
2.5 KiB
Bash
Executable file
#!/bin/sh
|
|
# Check if a commit or code change has been released (is contained in any version tag)
|
|
#
|
|
# Usage:
|
|
# ./scripts/check-if-released <commit-hash>
|
|
# ./scripts/check-if-released <commit-hash> --details
|
|
#
|
|
# Examples:
|
|
# ./scripts/check-if-released f4568be
|
|
# ./scripts/check-if-released HEAD~3 --details
|
|
|
|
set -e
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Check if commit hash provided
|
|
if [ -z "$1" ]; then
|
|
echo "Usage: $0 <commit-hash> [--details]"
|
|
echo ""
|
|
echo "Examples:"
|
|
echo " $0 f4568be"
|
|
echo " $0 HEAD~3 --details"
|
|
exit 1
|
|
fi
|
|
|
|
COMMIT="$1"
|
|
DETAILS="${2:-}"
|
|
|
|
# Validate commit exists
|
|
if ! git rev-parse --verify "$COMMIT" >/dev/null 2>&1; then
|
|
printf '%bError: Commit '\''%s'\'' not found%b\n' "$RED" "$COMMIT" "$NC"
|
|
exit 1
|
|
fi
|
|
|
|
# Get full commit hash
|
|
FULL_HASH=$(git rev-parse "$COMMIT")
|
|
SHORT_HASH=$(git rev-parse --short "$COMMIT")
|
|
|
|
# Get commit info
|
|
COMMIT_SUBJECT=$(git log -1 --format="%s" "$COMMIT")
|
|
COMMIT_DATE=$(git log -1 --format="%ci" "$COMMIT")
|
|
|
|
echo "Checking commit: $SHORT_HASH"
|
|
echo "Subject: $COMMIT_SUBJECT"
|
|
echo "Date: $COMMIT_DATE"
|
|
echo ""
|
|
|
|
# Check if commit is in any version tag (v*.*.*)
|
|
TAGS=$(git tag --contains "$COMMIT" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' || true)
|
|
|
|
if [ -z "$TAGS" ]; then
|
|
printf '%b✓ NOT RELEASED%b\n' "$GREEN" "$NC"
|
|
echo "This commit is not part of any version tag."
|
|
echo ""
|
|
printf '%b→ No legacy migration needed for code introduced in this commit%b\n' "$YELLOW" "$NC"
|
|
exit 0
|
|
else
|
|
printf '%b✗ ALREADY RELEASED%b\n' "$RED" "$NC"
|
|
echo "This commit is included in the following version tags:"
|
|
echo "$TAGS" | sed 's/^/ - /'
|
|
echo ""
|
|
printf '%b⚠ Breaking Change Decision:%b\n' "$YELLOW" "$NC"
|
|
echo " 1. If migration is SIMPLE (e.g., .lower(), key rename) → Add it"
|
|
echo " 2. If migration is COMPLEX → Document in release notes instead"
|
|
echo " 3. Home Assistant style: Prefer breaking changes over code complexity"
|
|
echo ""
|
|
|
|
if [ "$DETAILS" = "--details" ]; then
|
|
echo ""
|
|
echo "First release containing this commit:"
|
|
FIRST_TAG=$(echo "$TAGS" | head -1)
|
|
echo " Tag: $FIRST_TAG"
|
|
git log -1 --format=" Date: %ci" "$FIRST_TAG"
|
|
|
|
echo ""
|
|
echo "Latest release:"
|
|
LATEST_TAG=$(git tag -l 'v*.*.*' --sort=-version:refname | head -1)
|
|
echo " Tag: $LATEST_TAG"
|
|
git log -1 --format=" Date: %ci" "$LATEST_TAG"
|
|
fi
|
|
|
|
exit 1
|
|
fi
|