git hooks 之 commit-msg

将commit-msg.sample修改为commit-msg

在最后添加 以下内容:

# 检测提交日志是否符合规范

#默认如下且type:与BugID:后面不能为空:

#type:

#BugID:

log_message=$1

for line in `cat ${log_message} | grep -v "^$"`;do 
    if [ "${line%%:*}" != "type" -a "${line%%:*}" != "BugID"  ];then
        echo "Log Message don't conform to specification,Please check it."
        exit 1 
    else
        if [ -z "${line#*:}" ];then
            echo "${line%%:*}: is empty,Please check it."
            exit 1
        fi
    fi
done

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章