#!/bin/sh
echo >&2 start check msg...
#test "" = "$(grep '^Signed-off-by: ' "$1" |
# sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
# echo >&2 Duplicate Signed-off-by lines.
# echo >&2 No 2025.10.23.
# exit 1
#}
#dos2unix .git/hooks/pre-commit
commit_msg_file="$1"
# 跳过 merge 提交(以 Merge 开头)
if head -n1 "$commit_msg_file" | grep -q "^Merge "; then
exit 0
fi
# 检查是否包含版本日期
if ! grep -q "2025.09.10" "$commit_msg_file"; then
echo >&2 "❌ Commit message must contain '2025.09.10'."
exit 1
fi
# 项目人员信息
footer=""
if grep -q "P001" "$commit_msg_file"; then
# 追加到文件末尾
footer="经理:张三 开发:wc88 测试:李四"
printf "%s" "$footer" >> "$commit_msg_file"
fi
if grep -q "P002" "$commit_msg_file"; then
# 追加到文件末尾
footer="经理:张三2 开发:wc88 测试:李四2"
printf "%s" "$footer" >> "$commit_msg_file"
fi
if ! grep -q "wc88" "$commit_msg_file"; then
echo >&2 "❌ Commit message must contain 'wc88'."
exit 2
fi
exit 0
项目:P001
功能:自动增加一行
版本时间:2025.09.10
441

被折叠的 条评论
为什么被折叠?



