mkdir setting #添加setting文件夹 cd setting #切换到setting文件夹 touch autoHooks.bat #添加批处理文件,可以使用vim编辑 vi autoHooks.bat ---------------------------- # 添加框内代码到autoHooks.bat @echo off set "curDir=%cd%" echo ------------------------------- set "curDir=%curDir:setting=%"
set source=%cd%\commit-msg.sample set dest=%curDir%.git\hooks\commit-msg echo %source% echo %dest% copy "%source%" "%dest%"
echo -------------------------------
----------------------------
touch commit-msg #创建commit-msg文件
----------------------------- # 添加框内文件到commit-msg #!/bin/bash #!/bin/bash MSG=`awk '{printf("%s",$0)}' $1` if [[ $MSG =~ ^(feat|fix|test|refactor|docs|style|chroe)\(.*\):.*$ ]] then echo -e "\033[32m commit success! \033[0m" else echo -e "\033[31m Error: the commit message is irregular \033[m" echo -e "\033[31m Error: type must be one of [feat,fix,docs,style,refactor,test,chore] \033[m" echo -e "\033[31m eg: feat(文件): add the user login \033[m" exit 1 fi -----------------------------