#!/usr/bin/env bash
MSG=$(cat "$1")

# Conventional Commits: type(scope)!: description
PATTERN="^(feat|fix|docs|style|refactor|test|chore|perf|ci|build|revert)(\(.+\))?(!)?: .{1,}"

if ! echo "$MSG" | grep -qE "$PATTERN"; then
  echo ""
  echo "  提交信息不符合 Conventional Commits 规范"
  echo "  正确格式: type(scope): 描述"
  echo "  示例:"
  echo "    feat(onboarding): 新增接入包生成功能"
  echo "    fix(dashboard): 修复看板加载失败问题"
  echo "    chore: 更新依赖版本"
  echo ""
  exit 1
fi
