#!/bin/bash

# Check for conventional commits
commit_msg=$(cat "$1")
pattern='^(feat|fix|chore|docs|refactor|revert)\(.+\): .+'

if [[ ! "$commit_msg" =~ $pattern ]]; then
    echo -e "\e[31mERR:\e[0m Commit message does not follow conventional commits.\n"
    echo -e "Format  : <type>(<scope>): <description>\nExample : chore(ci): add bitbucket-pipelines.yml\nTypes   : feat, fix, chore, docs, refactor, revert\n"
    exit 1
fi

exit 0