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

 

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