#!/bin/bash
chmod +x verify-commit.sh

MESSAGE=$(git log -1 HEAD --pretty=format:%s)
echo -e "Checking for valid commit message..."
echo -e "Commit message ↴"

if echo "$MESSAGE" | grep -E "^(feat|fix|docs|style|refactor|perf|test|chore|BREAKING CHANGE):"; then
    GREEN='\033[1;32m'
    echo -e "\n$GREEN Success! Moving right along now...."

else
    RED='\033[1;31m'
    echo -e "\n$RED Not a valid commit style, what are you stupid?
    Please use one of the following at the begining on the commit message:\n
    fix: docs: style: refactor: perf: test: chore:
      ↳ Use one of these to update the patch version number\n
    feat:
      ↳ Use this to update the minor version number\n
    BREAKING CHANGE:
      ↳ Use this to update major verion number, case sentitive\n
    IMPORTANT NOTE: this is a modified version of angular commit,
    DO NOT USE SCOPE, it is not supported, eg. feat(scope): message"
    exit 1
fi
