#!/bin/sh
commit_msg=$(cat "$1")
pattern='^(feat|fix|chore|docs|style|refactor|test|build|ci|perf|revert)(\(.+\))?: [A-Z]+-[0-9]+ .+'

if ! echo "$commit_msg" | grep -qE "$pattern"; then
  echo ""
  echo "  Invalid commit message format."
  echo ""
  echo "  Required: <type>: <JIRA-TICKET-ID> <description>"
  echo "  Example:  feat: ET-4591 add release automation"
  echo ""
  echo "  Allowed types: feat, fix, chore, docs, style, refactor, test, build, ci, perf, revert"
  echo ""
  exit 1
fi
