datai/datai-scenes/datai-scene-salesforce/.githooks/commit-msg

38 lines
993 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# commit-msg钩子检查提交信息格式
set -e
commit_msg_file="$1"
commit_msg=$(cat "$commit_msg_file")
echo "=== 运行commit-msg检查 ==="
# 检查提交信息格式
if ! echo "$commit_msg" | grep -q "^\(feat\|fix\|docs\|style\|refactor\|test\|chore\): "; then
echo "错误:提交信息格式不正确"
echo "正确格式:<type>: <description>"
echo "类型包括feat、fix、docs、style、refactor、test、chore"
exit 1
fi
# 检查提交信息长度
if [ ${#commit_msg} -gt 50 ]; then
echo "警告提交信息描述过长建议不超过50字符"
fi
# 检查是否包含issue编号
if ! echo "$commit_msg" | grep -q "#\d\+"; then
echo "提示建议在提交信息中包含相关issue编号"
fi
# 检查是否是bootstrap提交
if echo "$commit_msg" | grep -q "bootstrap"; then
echo "✓ bootstrap提交跳过详细检查"
exit 0
fi
echo "✓ 提交信息格式正确"
echo "=== commit-msg检查完成 ==="