#!/bin/sh # 提交标题必须遵循中文 Conventional Commit。类型与功能编号用于机器检索, # 冒号后的中文摘要用于人类阅读。合并提交和回退提交由 Git 自动生成,予以放行。 message_file="$1" subject="$(sed -n '1p' "$message_file")" case "$subject" in Merge\ *|Revert\ *) exit 0 ;; esac if ! printf '%s' "$subject" | grep -Eq '^(feat|fix|docs|refactor|test|chore|build|ci|perf|style)(\([A-Z0-9-]+\))?!?: .+'; then printf '%s\n' '提交标题格式错误。示例:feat(FEAT-MO-001): 新增市场概览结论区' >&2 exit 1 fi if ! printf '%s' "$subject" | grep -Eq '[一-龥]'; then printf '%s\n' '提交摘要必须使用中文。' >&2 exit 1 fi