#!/bin/sh

echo "\033[32m Check commit message! \033[0m"
MSG=`awk '{printf("%s",$0)}' $1`
if [[ $MSG =~ ^\[(feat|fix|test|refactor|doc|style|chroe)\]:.*$ ]]
then
    echo "\033[32m commit success! \033[0m"
else
    echo "\033[31m Error: the commit message is irregular \033[m"
    echo "\033[31m Error: type must be one of [feat,fix,docs,style,refactor,test,chore] \033[m"
    echo "\033[31m eg: [feat]: add the user login \033[m"
    exit 1
fi
