#!/bin/sh

# Get the commit message
COMMIT_MSG_FILE=$1
COMMIT_MSG=$(cat $COMMIT_MSG_FILE)

# Define a regex pattern for the commit message
PATTERN="^(feat|fix|docs|style|refactor|test|chore|build|ci|perf|revert)(\(.+\))?: .{1,50}"

# Check if the commit message matches the pattern
if ! echo "$COMMIT_MSG" | grep -Eq "$PATTERN"; then
    echo "Commit message does not follow the convention!"
    echo "Commit message should start with one of the following types: feat, fix, docs, style, refactor, test, chore, build, ci, perf, revert"
    echo "Example: feat(parser): add ability to parse arrays"
    exit 1
fi

# COMMIT_MSG_FILE=$1
# commitlint
